Pattern-Based Problem Solving

Build a repeatable process for solving unseen problems: read constraints, map to known patterns, brute force first, optimise, test and review.

Intermediate · about 20 hours · difficulty 3/5

Learn first: Sliding Window, Binary Search, Graph Representation, BFS and DFS, Dynamic Programming Foundations (1D)

Solving 1000 random problems is less effective than solving 250 well-chosen ones deeply. The goal is to recognise patterns so an unseen problem feels like a variant of something you know.

A problem-solving routine

  • Read carefully and restate the problem. Work one example by hand.
  • Read the constraints to guess the target complexity (n = 10^5 means O(n log n) or better).
  • Write down the brute force and its complexity. This alone often earns partial credit in interviews.
  • Ask which pattern removes the bottleneck: hashing, two pointers, sliding window, binary search, heap, graph traversal, DP.
  • Code cleanly, then test edge cases: empty input, one element, duplicates, negatives, maximum sizes.

How to practise

  • Follow a curated list (NeetCode 150, Striver's A2Z sheet, Blind 75) topic by topic, then mix topics to practise recognition.
  • Time-box: if stuck for 30-45 minutes, read the editorial, then re-solve it from scratch a few days later.
  • Keep a mistake log: the problem, the pattern, and the insight you missed. Review it weekly.
  • Use spaced repetition: revisit problems after 3, 7 and 21 days.
  • Aim for a balance of roughly 30% easy, 60% medium, 10% hard for placements.

Signs you are ready

You can solve most mediums in 25-30 minutes, explain the complexity without hesitation, and you get fewer "wrong answer on edge case" verdicts.

Key concepts

  • Reading constraints for target complexity
  • Brute force first, then optimise
  • Pattern recognition checklist
  • Curated lists (NeetCode 150, A2Z sheet)
  • Mistake log and spaced repetition
  • Edge case testing
  • Stress testing against brute force

Mini project

Run a 4-week sprint: 5 problems per day following a curated list, log every problem in a spreadsheet (pattern, time taken, solved alone or not), and at the end of each week re-solve the 5 problems you struggled with most without notes.

Check yourself

Given a new problem with n up to 2 * 10^5 asking for a count over subarrays, which patterns would you consider first and why?

Free resources