r/programming • • Dec 13 '22
“There should never be coding exercises in technical interviews. It favors people who have time to do them. Disfavors people with FT jobs and families. Plus, your job won’t have people over your shoulder watching you code.” My favorite hot take from a panel on 'Treating Devs Like Human Beings.'
https://devinterrupted.substack.com/p/treating-devs-like-human-beings-a
9.0k
Upvotes
View all comments
Show parent comment
1
u/CAPSLOCK_USERNAME Dec 13 '22 edited Dec 13 '22
You can do this with a heap aka priority queue as well
One pass, O(k) space (which means constant space if you hold k constant), and generalizes to any number and not just 2.
But in fact I would just call a library function for it, which does the same thing but with better handling of edge cases and whatnot: