Day 13 — Revision: Strings & Sliding Window

revision day · strings · sliding window · blank-file recall

Tonight's goal: after the Longest Palindromic Substring teaching lesson, prove that the strings and sliding-window invariants can come back from memory. Do the teaching lesson first, then run this page.

Tonight's protocol

Use the revision-day protocol: blank file, no hints, and only the first or second run counts.

  1. Before this page: finish the Longest Palindromic Substring teaching lesson. Then close lesson notes, stored code, videos, and hints.
  2. 0:00-0:02: scan the menu below and pick your 3 weakest problems. Do not add outside problems.
  3. 0:02-0:05: answer the warm-up MCQs. Any miss becomes a risk note, not a reason to delay solving.
  4. 0:05-0:25: problem 1. State the pattern, invariant, brute force, and target complexity out loud; code from a blank file; submit at most twice.
  5. 0:25-0:45: problem 2. Same rule: blank file, no hints, two runs maximum.
  6. 0:45-1:05: problem 3. Keep the timer honest; passing after run three does not count as revised.
  7. 1:05-1:10: log each result. Passes get Revision Done. Fails get WA: <root cause> and stay in the next revision queue.

The problem menu

Pick your 3 weakest from this menu. Re-solve each from a blank file with no hints.

ProblemPattern nameInvariant cue
Valid Anagram Frequency Counting letter-count histograms must match
Valid Palindrome Two Pointers on Strings skip noise, compare inward
Longest Substring Without Repeating Characters Sliding Window I: The Shrinking Rule valid means no repeated character
Longest Repeating Character Replacement Sliding Window II: Validity With a Budget window size minus max frequency fits k
Minimum Window Substring Sliding Window III: Minimum Window window covers every needed count
Group Anagrams Frequency Counting histogram tuple is the grouping key

Warm-up MCQs

1. Which invariant proves Valid Anagram and Group Anagrams?

2. Which loop shape belongs to Valid Palindrome?

3. Spot the bug for s = "abba":

if ch in seen:
    seen.remove(s[left])
    left += 1
seen.add(ch)

4. Which rule keeps Character Replacement valid?

5. When does left move in Minimum Window Substring?

6. Which pattern name belongs to Group Anagrams?

Self-check gate

Pass bar for tonight

You pass only if all 3 chosen problems started from a blank file, no hints were used, and each counted problem passed on run one or run two.

Before coding each problem, you must be able to say its invariant: histograms match; skip and compare inward; grow right then shrink until valid; windowSize - maxFreq <= k; or window covers every needed count.

Failure path: if a problem fails after two runs, write WA: <root cause>, leave Revision Done unticked, and add that exact problem to the next revision queue. If the root cause is a missing invariant, ask your teacher with the problem link, your invariant attempt, and the failing code.