Solved

commonEnd  challenge

Posted on 2015-02-12
2
73 Views
Last Modified: 2015-02-13
Hi,

I am working on below challenge

http://codingbat.com/prob/p191991

public boolean commonEnd(int[] a, int[] b) {
int len1=a.length;
int len2=b.length;
int firstEle1=a[0];
int firstEle2=b[0];
int lastEle1=a[len1-1];
int lastEle2=b[len2-1];

return firstEle1==firstEle2 || lastEle1==lastEle2;


  
}

Open in new window


i wrote as above. I wonder how can i improve my code. Please advise
0
Comment
Question by:gudii9
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 40606547
Without the extra variables
 return a[0]==b[0] || a[a.length-1]==b[b.length-1];
0
 
LVL 7

Author Comment

by:gudii9
ID: 40606588
yes
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question