Solved

commonEnd  challenge

Posted on 2015-02-12
2
61 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
2 Comments
 
LVL 84

Accepted Solution

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

Author Comment

by:gudii9
Comment Utility
yes
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
changeXy challenge 13 56
maven java path setting 5 49
mapBully challenge 6 88
eclipse compiler vs Installed JREs option 3 38
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now