Get the kth largest number from two sorted arrays
Anonymous
// return kth biggest element from 2 sorted arrays public static int kthElement (int[] a1, int[] a2, int k){ int i1 = a1.length-1; int i2 = a2.length-1; for (int i =1; i a2[i2]) { i1--; } else { i2--; } } if (a1[i1] > a2[i2]) return a1[i1]; else return a2[i2]; }
Check out your Company Bowl for anonymous work chats.