double getKth(int[] a, int[] b, int k) {
		int m = a.length;
		int n = b.length;

		if (n == 0)
			return a[k - 1];
		if (m == 0)
			return b[k - 1];
		if (k == 1)
			return Math.min(a[0], b[0]);

		// divide k into two parts
		int p1 = Math.min(k / 2, m);
		int p2 = Math.min(k - p1, n);

		if (a[p1 - 1] < b[p2 - 1])
			return getKth(Arrays.copyOfRange(a, p1, m), b, k - p1);
		else if (a[p1 - 1] > b[p2 - 1])
			return getKth(a, Arrays.copyOfRange(b, p2, n), k - p2);
		else
			return a[p1 - 1];
	
	}