Search Tech Journey

Find topics, journeys and posts

back to blog
algorithmsadvanced 75m read

L60 · Weak-Pattern Intensive

Take the bottom three patterns from the L59 audit and repair them with the rebuild loop: blind template, three costumes, interleaved re-test.

🧩DSAPhase 4 · Interview simulation· Session 060 of 130 75 min

🎯 Repair the bottom three patterns from the L59 audit using a fixed rebuild loop — blind template, three differently-costumed problems, then an interleaved re-test that proves the repair held.

Series: LeetCode — From Basics to Interview-Ready · Session 60 / 65 · Phase 4 · Interview simulation

Why this session exists

L59 produced a ranked list of patterns you cannot retrieve. This session repairs the top three, and it is the highest-leverage seventy-five minutes in the whole track, because targeted repair beats uniform grinding by a wide margin and you now have the targeting information.

The reason it beats uniform grinding is arithmetic. If you have twenty-eight patterns and three are broken, an hour spread evenly across all of them gives each broken pattern about two minutes. An hour spent entirely on the three gives each twenty. The interview outcome depends on whichever pattern shows up, so the expected value of fixing a broken pattern is far higher than the value of polishing a working one — and yet almost nobody allocates this way, because working on your weak patterns is unpleasant and working on your strong ones feels productive.

The other reason this session exists is that "practise more X" is useless advice without a procedure. Below is the procedure. It is the same four steps for every pattern, it takes twenty-five minutes, and it ends with a test that tells you whether the repair actually took.

Blank-file warm-up

Your two weakest templates, from the L59 table. Blank file, no notes, five minutes total.

This is not a warm-up in the usual sense — it is the pre-measurement. Whatever comes out is the baseline you compare against at the end of the session. Write it down even if it is three broken lines. Especially then.

If you cannot remember which two are weakest, the audit table did not get written properly and you should go back and do L59 before this session. Guessing at your weak patterns reproduces exactly the bias the audit existed to remove.

Pattern anatomy

The pattern today is the rebuild loop — a fixed procedure for converting a broken pattern into a retrievable one.

The invariant: at every stage, you are working without the previous stage's support. Read the template, then reproduce it without the template. Solve a problem, then solve a differently-costumed one without re-reading the first. Each step removes a scaffold. That removal is where the consolidation happens; a loop that keeps the scaffolds present produces familiarity and not retrieval.

# THE REBUILD LOOP — 25 minutes per pattern, 3 patterns per session.
#
# STEP 1 — RE-DERIVE, DON'T RE-READ (5 min)
#   Do NOT open your old notes first. Try to reconstruct the template from the IDEA.
#   Ask: what is this pattern's invariant? What does each pointer/state variable mean?
#   Only after failing at that, open the notes — and then close them and write it again.
#   The re-derivation attempt is what makes the reading stick. Reading first wastes it.
#
# STEP 2 — ONE GUIDED, THREE COSTUMES (12 min)
#   Pick 3 problems of the SAME pattern that look maximally different from each other.
#   Solve the first with your template visible. Close the template. Solve the other two
#   without it. Varied surface + same underlying shape is what builds the classifier;
#   three near-identical problems build nothing.
#
# STEP 3 — WRITE THE CUE CARD (3 min)
#   Two lines, in your own words:
#     "I reach for this when: <the textual/constraint tells>"
#     "The invariant is: <one sentence>"
#   Own words, not the ones from this blog. Rephrasing is a retrieval act.
#
# STEP 4 — INTERLEAVED RE-TEST (5 min)
#   Blank file. Write the template again, cold.
#   Then do the same for the OTHER two patterns from today, in mixed order.
#   Interleaving is uncomfortable and is what makes the repair survive the week.

The interleaving in step 4 is the part people cut when time runs short, and it is the part that does the work. Practising pattern A three times in a row produces fluency that evaporates by tomorrow. Practising A, B, C, A, C, B feels worse in the moment and retains dramatically better. Trust the discomfort.

The cue

Run a weak-pattern intensive rather than ordinary practice when:

  1. You have a measured weak list less than a week old. Older than that and the data has drifted; re-sweep the affected patterns first.
  2. The failures are retrieval failures, not novelty failures. If you failed a pattern because you had never seen it, that is a learning gap and you need the original session, not a repair loop.
  3. The same pattern failed in both the L57 mock and the L59 audit. A double hit is the strongest possible signal and that pattern goes to the top of the list regardless of counts.
  4. You catch yourself avoiding a pattern when choosing practice problems. Avoidance is a reliable indicator and it never shows up in a solve count.
  5. A pattern is common in interviews and you rated it below cold. Weight by frequency: a shaky sliding window matters more than a shaky segment tree, because one of them appears constantly and the other almost never.

Guided solve

No fixed problem, because your three patterns are yours. Here is the loop applied to a worked example so the shape is concrete — substitute your own pattern for the one used here.

Suppose the audit put sliding window in your bottom three.

Step 1, re-derive (5 min). Do not open notes. Ask what the invariant is. The window [left, right] always satisfies some condition; right expands to include new elements; left advances only when the condition breaks. That is the idea, and from the idea the skeleton follows: outer loop over right, inner while that shrinks from left, an update to the answer positioned depending on whether you want the longest valid window or the shortest.

Now write it:

def longest_valid_window(arr):
    left = 0
    best = 0
    state = {}                       # whatever the condition needs
    for right, x in enumerate(arr):
        # 1. include x in state
        state[x] = state.get(x, 0) + 1
        # 2. shrink while the window is INVALID
        while not condition_holds(state):
            y = arr[left]
            state[y] -= 1
            if state[y] == 0:
                del state[y]
            left += 1
        # 3. window is valid here -> update answer
        best = max(best, right - left + 1)
    return best

Compare against your notes. Note precisely what you got wrong — not "I forgot the shrink", but "I updated best inside the while loop instead of after it". That specific error is the thing to watch for in step 4.

Step 2, three costumes (12 min). Choose problems that look nothing alike but share the shape. For sliding window: "longest substring without repeating characters" (state is a set), "minimum window substring" (state is a counter, and it is a minimising window so the answer update moves inside the shrink loop), "max consecutive ones III" (state is a single integer count of flips used). Same skeleton, three completely different-looking statements, and one of them inverts where the answer update goes — that variation is the most valuable of the three.

Solve the first with your template open. Close it for the other two.

Step 3, cue card (3 min). In your own words. Something like: "I reach for this when the problem says contiguous subarray or substring and asks for a longest/shortest/count satisfying a condition that can be maintained incrementally. The invariant is that the window between left and right is the best candidate ending at right."

Step 4, interleaved re-test (5 min). Blank file. Sliding window template. Then your second pattern. Then your third. Then back to the first. Mixed order, no notes.

Repeat the whole loop for patterns two and three.

Solo timed

The three rebuild loops are the session. Twenty-five minutes each, and the twelve-minute problem block inside each loop is the timed part — roughly four minutes per problem.

Hints for the patterns that most commonly land in the bottom three:

  • Dynamic programming — if DP is on your list, do not attempt three DP problems. Attempt one, and spend the rest of the loop on state definition alone: write down what dp[i] means in English for five different problems without solving any of them. State definition is almost always the actual failure.
  • Backtracking — the failure is usually the undo step, not the recursion. Drill choose/explore/unchoose specifically, on three problems with different constraint types.
  • Monotonic stack — the failure is almost always the direction of the comparison and what gets stored (indices, not values). Write the two variants side by side: next-greater and next-smaller.
  • Graphs — check whether the failure is the traversal or the representation. If you can write BFS but stall on building the adjacency list from an edge list, the repair is the parsing, not the algorithm.

Common failure modes

Reading the notes before attempting the re-derivation. This is the big one. Reading first turns the exercise into recognition, and recognition is exactly the thing that felt fine during practice and failed in the mock. The failed attempt is not wasted time — it is what makes the subsequent reading stick.

Choosing three similar problems. Three sliding-window problems that all use a character-frequency counter train one costume. The classifier only improves when the surface varies and the shape does not.

Blocking instead of interleaving. Doing pattern A three times, then B three times, then C three times feels better and retains worse. Mixed order in step 4 is not optional.

Repairing five patterns instead of three. The loop takes twenty-five minutes honestly executed. Five patterns means fifteen minutes each, which means the interleaved re-test gets cut, which means you did five shallow reviews instead of three repairs.

Skipping the cue card because it feels like busywork. The cue card is the classification half of the pattern, and classification was the thing the mock exposed. Writing it in your own words is a retrieval act, not documentation.

Not re-testing at the end. Without step 4 you have no evidence the repair took, and you will assume it did. Then L61 finds out otherwise under a clock.

Common misconception
✗ What most people think
I should work on my strongest patterns to make them airtight, since those are the ones I'll actually use in an interview.
Why the myth is so sticky
You do not get to choose the pattern. The interviewer picks the problem, so your effective level is set by whichever pattern shows up — which makes the weakest common pattern the binding constraint, not the strongest. Polishing a pattern from strong to very strong changes almost nothing about the outcome distribution, while moving one from broken to functional removes a whole category of failure. The pull toward strong patterns is real and it is about comfort: working on things you are good at feels like progress and produces no marginal capability.
From first principles
  1. 1
    Interview outcomes are decided by a single problem drawn from a distribution of patterns you do not control.
  2. 2
    Because the draw is not yours, expected performance is dominated by the patterns you cannot do rather than the ones you can.
  3. 3
    Because the weak patterns dominate, marginal effort is worth far more at the bottom of your distribution than at the top.
  4. 4
    Because repair requires retrieval rather than review, the loop must remove its own scaffolds at each step — re-derive before reading, solve without the template, re-test cold.
  5. 5
    Because retrieval consolidates better when practice is varied and interleaved rather than blocked, the three problems must look different and the re-test must mix patterns.
  6. 6
    Therefore the rebuild loop is re-derive, three costumes, cue card, interleaved re-test — and the testable prediction is that a pattern repaired this way is still retrievable at the L65 re-audit, whereas one merely re-read will have decayed back to its L59 status.
Mental model
Physiotherapy after an injury, not general fitness training. You do not strengthen the whole body uniformly — you find the specific damaged movement, load it deliberately, and re-test the movement itself to confirm the repair.
🔔 Fires when you see
Fires whenever you are about to choose a practice problem and reach for something you know you are good at.
The tradeoff
Targeted repair on the audited bottom three
+ you gain Attacks the binding constraint directly; each pattern gets enough time for the loop to complete; the re-test gives immediate evidence of whether it worked
− you pay Uncomfortable throughout; the visible solve count for the session is low; you leave twenty-five other patterns untouched today
Uniform review across all patterns
+ you gain Feels thorough; everything gets touched; comfortable because most of it goes well
− you pay Gives each weak pattern two minutes, which is not enough to repair anything; mostly reinforces what already worked; the weak list is unchanged at the next audit
What a senior engineer actually does
Targeted repair whenever you have an audit less than a week old. Fall back to uniform review only when no audit exists — and in that case run L59 first instead, since an hour of measurement beats an hour of undirected review.

Complexity

Per pattern: 5 min re-derive, 12 min three problems, 3 min cue card, 5 min interleaved re-test. Twenty-five minutes.

Per session: three patterns, seventy-five minutes. Three is the maximum that fits with the re-test intact, and cutting the re-test to fit a fourth is a bad trade.

Retention cost: each repaired pattern needs one re-test within seven days or it decays back toward its audit status. Schedule those re-tests now, not later — they are five minutes each and they are what make today permanent.

Why three problems per pattern and not five: the marginal problem within a session adds less than the marginal costume. Three visibly different problems beat five similar ones, and the time saved goes into the re-test, which is worth more than either.

Quick recall · click to reveal
★ = stretch question

Spaced queue

Today's three patterns get scheduled aggressively, because a fresh repair is fragile:

  • Re-test each repaired template cold in 2 days, blank file, five minutes.
  • If that passes, next check in 7 days, then normal ladder.
  • If it fails, the pattern goes back to failed and gets another full rebuild loop, not a re-read.

Everything else in the queue runs on the standard ladder: cold +60d, warm +21d, hint +7d, failed +2d then +7d.

Update the L59 table with today's outcomes. That table is the input to L65's comparison and it is only useful if it stays current.

Key points