Solved

commonEnd  challenge

Posted on 2015-02-12
2
62 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 85
listing all functions in JavaScript 19 176
table example 4 21
Windows 10 IE Certificate Issue 10 41
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

911 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

21 Experts available now in Live!

Get 1:1 Help Now