TL;DR
- Strings and windows are common because they reward precise state tracking.
- I practice them as parsing and UI-search problems, not just textbook substring exercises.
- The key move is defining exactly what makes the current window valid.
Context
Frontend work constantly touches strings: search boxes, route parsing, query handling, template variables, validation, and text transforms. Sliding window helps when I need contiguous ranges without nested loops.
The Approach
Practice these 10 medium-level questions:
- Longest Substring Without Repeating Characters — canonical variable-window problem.
- Minimum Window Substring — track deficits precisely.
- Longest Repeating Character Replacement — balance window size with tolerated replacements.
- Valid Palindrome II — allow one deletion with pointer branching.
- Group Shifted Strings — normalize relative character offsets.
- Find All Anagram Start Indices — fixed-size window frequency matching.
- Compare Version Strings — parse segments without naive lexical compare.
- Decode Encoded String — nested pattern parsing like
3[a2[c]]. - Template Placeholder Expansion — replace tokens from a map with fallback handling.
- Longest Common Prefix After Sorting — comparator plus prefix scan.
Try it in the browser
Browser Practice
String practice: longest unique substring length
Implement solve(value) and return the length of the longest substring with no repeated characters.
Sample Tests
3 checks
Function name:
solveBest for JavaScript / TypeScript / JSON practice snippets.Monospace editorRuns in browser sandbox
Trade-offs
- Sliding window is powerful, but only when the invariant is clear.
- Pointer-based solutions are fast, but they become fragile if I do not document what each boundary means.
References
- Related: Coding Practice: Arrays
- Related: Coding Practice: Searching