Problem 658 · Medium

Find K Closest Elements

Pick a window of k numbers from a sorted list that sits nearest a target. The visual slides two pointers inward, dropping whichever end is farther away.

Open the interactive visualisation