Top K frequent elements and K closest points
Two warm-up style problems that the interviewer combined into one round:
- Return the
kpoints closest to the origin. - Return the
kmost frequent values in a list.
Then combine them: rank items by frequency and break ties (or filter) by distance. Discuss heap versus quickselect and their complexity.
No answer yet. Write the first one; the best answer gets endorsed.
