/the study roomby harrycodecraft

DSA / Chapter 02 of 04

Think in patterns before you code.

Strong problem solving is less about remembering hundreds of answers and more about recognizing the shape of the next useful move. Open a pattern when you want the reasoning, not just a template.

Weeks 4-7

Thirteen high-signal patterns for common interview problem shapes.

Chapter outcomeTurn an unfamiliar prompt into a smaller, testable plan.

Start with the signal. Then choose the tool.

The pattern library

These patterns are not shortcuts to memorize. They are ways to describe a problem, maintain an invariant, and remove work you no longer need to repeat.

Recognition comes from review.

The practice loop

For every problem, write down the signal you missed, the invariant you needed, and the moment the solution became smaller.

  1. ReadClarify inputs, outputs, constraints, and edge cases.
  2. NameChoose the pattern and state why it fits.
  3. ProveWrite the invariant before writing the loop.
  4. ReviewReturn later and solve it without the template.