How to find the kth smallest element in the union of two sorted arrays?
You’ve got it, just keep going! And be careful with the indexes… To simplify a bit I’ll assume that N and M are > k, so the complexity here is O(log k), which is O(log N + log M). Pseudo-code: For the demonstration you can use the loop invariant i + j = k, but … Read more