K Closest Points to Origin (LC #973) finds points nearest to . Meta expects QuickSelect for average, not just the heap solution. Partition by distance squared (no need for square root). If the partition index equals , return the first points. Otherwise recurse on the appropriate half. The points left of partition are all closer than those right of it. Order doesn't matter in the output. Meta tests if you can apply QuickSelect to non-integer comparisons.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/sorting-searching/k-closest-points-to-origin
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████████████████████████████████████████████████████████████████████████████████████████