DSA series #01 · interactive
DSA is not about writing code. It is about spotting the pattern and knowing more than one way to solve it. Here is the classic example: find two numbers that add up to 24.
Try each number with every number after it.
4 + 11 = 15 ≠ 24
1
checks
Trade-off: No extra memory, easy to get right. Falls over once n grows. time O(n²) · extra memory O(1)
With 8 numbers, checking every pair is not slow, and sorting first actually costs more. Big-O ignores constants and small inputs. That is why you measure before you optimise.
log scale · 1 check = 1 ns
Same problem, same answer. At a million numbers the pair check takes minutes, the hash map about a millisecond. Knowing the pattern is what lets you pick.