AlgoViz
← All drills
🧠 Drill · Think it through

Sort first, then it's easy

The problem

You're given a pile of event timestamps in no particular order and a window k. Return whether any two events happened within k of each other. The timestamps arrive jumbled, and a close pair could be anywhere in the pile.

Don't jump to code. Walk the four questions an expert asks first — you'll build the habit, not just the answer.

1

Restate it

Before anything else — did you read what's actually being asked? Strip the story to the bare goal.

Strip away the story. What are we actually asked to find?