3 ms·
by using an N element max/min heap and evicting the max/min when a new element comes in that's less than the max/greater than the min (note this is also a leetc
by throwlaplace 7y ago
by using an N element max/min heap and evicting the max/min when a new element comes in that's less than the max/greater than the min (note this is also a leetcode problem https://leetcode.com/problems/k-closest-points-to-origin/ https://leetcode.com/problems/k-closest-points-to-origin/)
- glofish 7y agonothing wrong with knowing the answer or where to look it up, I don't get what your point is the purpose of the interview is to filter out people that do not know the answer or have pre-learned something and don't fully understand its applications. When you are in a dialog it is a very different dynamic, people that would not ask a question because it is already posted on leetcode are the problem the OP complains about