4 ms·
It can be done on O(nk log k) if you always merge two shortest list. If all the lists have length k initially it can be easily done with couple of loops as all
by Karliss 9y ago
It can be done on O(nk log k) if you always merge two shortest list. If all the lists have length k initially it can be easily done with couple of loops as all the lists will have the same length - n in the beginning, 2n after fist iteration, 4n after second.
- Karliss 9y agoHere is a quick implementation https://gist.github.com/karliss/ebc27b0b2baa3e6fc0f50fadda733554 https://gist.github.com/karliss/ebc27b0b2baa3e6fc0f50fadda73...