3 ms·
If the data structures can be split (as it seems), then the first step should be to get the head k element of both collections, so we only have to work with a m
by szemet 9y ago
If the data structures can be split (as it seems), then the first step should be to get the head k element of both collections, so we only have to work with a maximum of 2k elements. Then the solution is not O(2 * log(N)) but O(2 * log(min(N,2k))).
- jacksontale 9y agoGood thought, and also if k < N / 2
- jacksontale 9y agoEdited the post and added your comment