@Test public void getKthElementInTwoArray() { int N = 100000; Random r = new Random(); for (int i = 10; i <= N * 5; i += r.nextInt(i)) { int[] A = getRandomArray(N, -i / 2, i / 2); int[][] input = new int[2][]; checkOneSituation(A, r.nextInt(A.length), input); int k = r.nextInt(A.length); long st = System.nanoTime(); Assert.assertEquals(A[k], SelectionInTwoSortedArray.getKthElementInTwoArray(input[0], input[1], k + 1)); Assert.assertTrue((System.nanoTime() - st) < oneMilliSec); } }
public static int getKthElementInTwoArray(int[] A, int[] B, int k) { if (k <= 0 || k > A.length + B.length) { throw new IllegalArgumentException("invalid k " + k); } return help(A, B, k); }
SelectionInTwoSortedArray { public static int getKthElementInTwoArray(int[] A, int[] B, int k) { if (k <= 0 || k > A.length + B.length) { throw new IllegalArgumentException("invalid k " + k); } return help(A, B, k); } }
SelectionInTwoSortedArray { public static int getKthElementInTwoArray(int[] A, int[] B, int k) { if (k <= 0 || k > A.length + B.length) { throw new IllegalArgumentException("invalid k " + k); } return help(A, B, k); }  }
SelectionInTwoSortedArray { public static int getKthElementInTwoArray(int[] A, int[] B, int k) { if (k <= 0 || k > A.length + B.length) { throw new IllegalArgumentException("invalid k " + k); } return help(A, B, k); }  static int getHalfOfNthElementInTwoSameLengthArray(int[] A, int[] B); static int getHalfOfNthElementInTwoArray(int[] A, int[] B); static int getKthElementInTwoArray(int[] A, int[] B, int k); }
SelectionInTwoSortedArray { public static int getKthElementInTwoArray(int[] A, int[] B, int k) { if (k <= 0 || k > A.length + B.length) { throw new IllegalArgumentException("invalid k " + k); } return help(A, B, k); }  static int getHalfOfNthElementInTwoSameLengthArray(int[] A, int[] B); static int getHalfOfNthElementInTwoArray(int[] A, int[] B); static int getKthElementInTwoArray(int[] A, int[] B, int k);  }