All Patterns

Strings

Parse, build, and match strings with scanning, simulation, and dedicated string-matching algorithms.

When to use

  • Parsing or formatting (atoi, roman numerals, count-and-say)
  • In-place character simulation
  • Pattern matching (KMP, Rabin-Karp, Manacher)
  • Building output character by character

When NOT to use

  • A sliding window or two-pointer view fits better
  • The real subproblem is dynamic programming on substrings

Common traps

  • 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

Problems (9)

#5Check if All A's Appears Before All B's
easyFREE
#9Longest Common Prefix
easyFREE
#23Length of Last Word
easyFREE
#220Zigzag Conversion
medium
#221String to Integer (atoi)
medium
#222Count and Say
medium
#301KMP Algorithm
medium
#302Rabin-Karp String Matching
medium
#303Manacher's Algorithm
hard