• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 94
  • Last Modified:

commonEnd challenge

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
gudii9
Asked:
gudii9
1 Solution
 
ozoCommented:
Without the extra variables
 return a[0]==b[0] || a[a.length-1]==b[b.length-1];
0
 
gudii9Author Commented:
yes
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now