Find max k elements among mostly sorted list.
Anonymous
Why would you sort the whole thing when you only need the top k? Any sort algorithm will take you at least nLog(n). But maybe, and probably, n>>k. You go over the original list O(n) and insert in a Heap, keeping only k elements. It's gonna be O(n Log(k)).
Check out your Company Bowl for anonymous work chats.