Question DSA-SRCH-0064
HardWhat is the output of this code?
def kth_two(a, b, k):
if len(a) > len(b): a, b = b, a
if not a: return b[k - 1]
if k == 1: return min(a[0], b[0])
i = min(len(a), k // 2); j = k - i
if a[i - 1] < b[j - 1]:
return kth_two(a[i:], b, k - i)
return kth_two(a, b[j:], k - j)
print(kth_two([1, 3, 8, 9, 15], [7, 11, 18, 19, 21, 25], 6))
- A.
9
- B.
11
- C.
Sign up free to see the answer and a step-by-step explanation.