K Closest Points to Origin · Compound Engineer

K Closest Points to Origin

Return the k points nearest the origin. Why a max-heap of size k beats sorting everything, and why the heap's top is always the point to throw out.

DSAFreeMediumStep-through playerBy Aayush OstwalSolve on LeetCode ↗
Spotted a mistake in this lesson?Report an issue →