Strings
Parse, build, and match strings with scanning, simulation, and dedicated string-matching algorithms.
- • Parsing or formatting (atoi, roman numerals, count-and-say)
- • In-place character simulation
- • Pattern matching (KMP, Rabin-Karp, Manacher)
- • Building output character by character
- • A sliding window or two-pointer view fits better
- • The real subproblem is dynamic programming on substrings
- • Off-by-one on substring indices
- • Forgetting empty-string and whitespace edge cases
- • Rebuilding strings in a loop (O(n^2))
Key Invariant
Decide up front whether you scan once, simulate state, or precompute a matching table