Start with 2 int arrays, a and b, each length 2. Consider the sum of the values in each array. Return the array which has the largest sum. In event of a tie, return a.
biggerTwo([1, 2], [3, 4]) → [3, 4]
biggerTwo([3, 4], [1, 2]) → [3, 4]
biggerTwo([1, 1], [1, 2]) → [1, 2]
1 2 3 4 5 6 7 8 9 10 11 |
public int[] biggerTwo(int[] a, int[] b) { int sum_a; int sum_b; sum_a=a[0]+a[1]; sum_b=b[0]+b[1]; if (sum_a>=sum_b){ return a; }else{ return b; } } |