commonEnd  challenge

Posted on 2015-02-12
Medium Priority
Last Modified: 2015-02-13

I am working on below challenge


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
Question by:gudii9
LVL 85

Accepted Solution

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

Author Comment

ID: 40606588

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Suggested Courses

597 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