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.
Use the revision-day protocol: blank file, no hints, and only the first or second run counts.
WA: <root cause> and stay in the next revision queue.Pick your 3 weakest from this menu. Re-solve each from a blank file with no hints.
| Problem | Pattern name | Invariant 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 |
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?
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.