Problems > Closest to the Origin > Editorial

Closest to the Origin — Solution & Editorial

Back to the Problem

Compare SQUARED distances in integers (no sqrt, no floats); the tuple (d², x, y) implements the tie-break directly.

Complexity: O(N)