Top K frequent elements and K closest points

0
Remix

Two warm-up style problems that the interviewer combined into one round:

  1. Return the k points closest to the origin.
  2. Return the k most 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.

GoogleTechnical phone screenLast asked Feb 2026
No answer yet. Write the first one; the best answer gets endorsed.