Solved

commonEnd  challenge

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
web services creation SOAP vs REST 5 37
Zip Folders Using Chilkat Routines 1 36
hibernate example using maven 12 41
How to convert from xls to xlsx using java 7 35
Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
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 …
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…
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.

813 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

10 Experts available now in Live!

Get 1:1 Help Now