interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/6

Unit 1 · Algorithms · Lesson 24 of 24

Pattern recognition and mixed practice

Pattern recognition means mapping signals in a problem statement to a short list of candidate techniques and the condition each relies on, then checking the fit. This topic provides a recognition guide, a mixed-practice routine and a review rotation that revisits each pattern through a different problem, so skills transfer to unseen questions instead of memorized answers.
About 6 hFocus mode

Step 1: Learn the ideas

  • Signals to candidate patterns
  • Applicability conditions and invariants
  • Constraints as complexity hints
  • Stateful data-structure design
  • Combining patterns
  • Mixed (interleaved) practice
  • Spaced review through new problems
  • Practice logs and weakness tracking
  • Using LeetCode 75 and Top Interview 150 as pools

Why it matters

Interview problems come from a large space, and you will rarely meet one you have practiced. What transfers is the ability to read a statement, notice its signals and test a few candidate techniques against their preconditions. Memorizing solutions, or lists of questions said to be used by particular companies, does not build that ability and fails as soon as a problem is altered. Learning research also generally favors interleaved practice and spaced review over blocked repetition: mixing problem types forces you to choose the technique, which is precisely the skill being tested.

Core ideas

Signals, candidates, conditions. Read the constraints and the question, map them to a short list of candidates, and check each candidate's condition before committing.

SignalCandidate patternsCondition or invariant to check
Complement lookup, duplicates, groupinghashing, frequency countingEqual keys identify equivalent items
Pairs in sorted input, in-place partitioningtwo pointersEach move discards candidates that cannot improve the answer
Contiguous subarray or substringsliding window, prefix sumsWindow validity is monotone (often needs non-negative values); otherwise prefix sums with a hash map
Sorted input, or smallest feasible valuebinary search, binary search on the answerA predicate that flips from false to true exactly once
Overlapping ranges, many range updatessorting, interval merging, sweep lineSort key matches the objective
Nested structure, matching, undostackTop is the most recent unresolved item
Next greater or smaller, window extremesmonotonic stack or dequeStored indices stay in monotone order
k largest, running median, merging streamsheap selection, two heapsHeap top is the current extreme; size stays bounded
Reordering a list, cycles, middleslinked-list pointers, fast and slow pointersSave next before rewiring; fast moves twice as far
Hierarchy, subtree answerstree DFS or BFS, BST invariantEach subtree returns a summary its parent can combine
Many prefix queries over wordstrieEach node represents one prefix
Minimum steps, grids, transformationsgraph BFS or DFS, grid as implicit graph, multi-source BFSUnit weights; mark visited on enqueue
Prerequisites, dependenciestopological ordering, cycle detectionAn order exists only for a DAG
Groups merging over timeunion-findUndirected, unions only
Cheapest weighted routeshortest pathsWeight sign decides Dijkstra or Bellman-Ford
All combinations or placementsbacktrackingChoose, recurse, undo; prune early
Count ways, best total over choicesDP (1D, grid, strings, knapsack)Overlapping subproblems with a valid evaluation order
A locally best choice looks safegreedyAn exchange argument exists
Independent halves, k-th order statisticdivide and conquerSubproblems do not overlap; write the recurrence
Parity, small sets encoded as masksbit manipulationWidth and signedness are explicit
Fast operations on changing datastateful designMap plus list, heap or sorted structure kept consistent

Constraints narrow the list: n up to about 20 allows exponential search, n around 10^3 allows O(n^2), and n around 10^5 or more needs O(n log n) or better.

Mixed practice routine. Once several topics are studied, stop practicing only by topic. A session is three unseen problems from different patterns, 25 to 35 minutes each, with the pattern unknown in advance; the official LeetCode 75 and Top Interview 150 plans and the extra items in each topic are good pools. Before coding, write the signals you noticed and two candidates with the reason for your choice. Afterwards, log the problem, the pattern, whether you recognized it unaided, the time taken and the bug class.

Review rotation. Revisit each pattern at growing intervals, for example after about 2, 7 and 21 days, through a different problem each time. If you learned sliding windows on Longest Substring Without Repeating Characters, review with Permutation in String, then Minimum Window Substring; for BFS, follow Number of Islands with Rotting Oranges, then 01 Matrix. Re-solving the same problem mostly tests memory of that answer. Patterns you recognized late or solved with bugs come back sooner.

Stateful design problems. LRU Cache, Time Based Key-Value Store, Snapshot Array and LFU Cache combine patterns: a hash map for direct access plus a linked list, heap or sorted list for order. State the invariant that links the structures and the cost of every operation.

Common misconceptions

  • "The strategy is to memorize the questions a company uses." Such lists cannot be verified, and you will rarely see the same problem; recognition and clean execution transfer.
  • "More problems solved means more progress." Many problems practiced by topic, always knowing the pattern beforehand, build less recognition than fewer problems practiced mixed.
  • "Review means re-solving the same problem." That rehearses one answer; review the pattern through a new problem.
  • "A signal determines the pattern." Signals suggest candidates; the applicability condition decides.

How to approach it

Start mixed practice once arrays and hashing, two pointers, trees, graph traversal and basic DP are studied, and run two or three mixed sessions per week alongside topic study. When a pattern fails repeatedly, return to its topic notes instead of grinding more problems of the same kind. Mid and senior loops typically add design-flavored problems and follow-up extensions, so keep stateful design in the rotation.

Suggested order

  1. 1For each row of the signals table, write the pattern’s invariant from memory; any you cannot state send you back to that topic first.
  2. 2Open the LeetCode 75 plan and, without solving, classify ten problems by signal and candidate pattern; check your guesses when you later solve them.
  3. 3Solve the stateful design set in order: LRU Cache, Insert Delete GetRandom O(1), Time Based Key-Value Store, then Snapshot Array, writing the invariant that links the structures for each.
  4. 4Start a practice log (problem, signals, pattern, recognized unaided or not, time, bug class) and run a first mixed session of three unseen problems from different patterns.
  5. 5Schedule reviews: each pattern returns after about 2, 7 and 21 days through a new problem from the topic’s extra items or the Top Interview 150 plan.
  6. 6Every two weeks, read the log, pick the two weakest patterns and re-study their topic notes before adding problems; use Design Twitter and LFU Cache as harder design reviews.

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • LeetCode 75 study planStart here

    LeetCode

    Compact official problem pool for a first mixed pass across the core patterns, used without looking at the section labels first.

    Open(opens in a new tab)Not checkable automatically, 5 Oct 2026
  • LeetCode Top Interview 150 study planStart here

    LeetCode

    Larger official pool with several problems per pattern, which makes it the main source of new problems for the review rotation.

    Open(opens in a new tab)Not checkable automatically, 5 Oct 2026
  • MIT 6.006 Introduction to Algorithms (Spring 2020)

    MIT OpenCourseWare

    Section: Lecture notes index

    Lists every lecture and recitation PDF; the recitation notes are compact refreshers on the reasoning behind a data structure or algorithm when a pattern keeps failing.

    Open(opens in a new tab)Link responded, 5 Oct 2026

Step 4: Practice

Use the two official study plans as pools for mixed sessions, not as checklists to finish in order: pick problems whose pattern you do not know in advance and log the signal that led you to the approach. The design problems exercise the stateful-design pattern, which combines several structures. Review every pattern, this one included, through a problem you have not solved before.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1Which signals suggest a sliding window, and what condition makes it valid?
  2. Question 2When does a minimum-steps problem need Dijkstra instead of BFS?
  3. Question 3Which signals point to DP rather than greedy, and how would you check?
  4. Question 4Which patterns did you recognize late in your last mixed session, and why?
  5. Question 5Why is reviewing a pattern through a new problem more useful than re-solving an old one?
  6. Question 6What invariant links the hash map and the linked list in an LRU cache?

You’re done when you can

  • State the applicability condition and invariant of every pattern in the signals table without notes.
  • Complete four mixed sessions of three unseen problems each, recognizing the pattern unaided in at least two of three problems in each of the last two sessions.
  • Keep a practice log with review dates for three weeks and revisit at least five patterns through problems you had not solved before.
  • Implement LRU Cache from scratch in under 25 minutes with O(1) operations and explain the invariant between the map and the list.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Your notes and study time

Log study time