biggerTwo([1, 2], [3, 4]) → [3, 4]
biggerTwo([3, 4], [1, 2]) → [3, 4]
biggerTwo([1, 1], [1, 2]) → [1, 2]
Answer 1:
public int[] biggerTwo(int[] a, int[] b) {
if(a[0]+a[1] < b[0]+b[1]) return b;
return a;
}
Answer 2:
public int[] biggerTwo(int[] a, int[] b) {
if (b[1] + b[0] > a[1] + a[0])
return b;
else
return a;
}
No comments :
Post a Comment