Skip to main content

πŸ”€ Strings

Strings are arrays of characters with a few extra twists: immutability, character sets, and pattern matching. Most string problems reduce to sliding window, hashing, or two pointers.

This category contains 71 problems. Use the patterns below to recognize what's being asked, then jump to the problem list at the bottom.


🧠 Key Patterns​

  • Sliding Window + Frequency Map β€” Longest/shortest substring with constraint on distinct chars or anagram windows.
  • Two Pointers from Ends β€” Palindrome checks, reversing in place.
  • Hashing & Frequency Counts β€” Anagram detection, group-by-signature.
  • Expand Around Center β€” All palindromic substrings in O(n2)O(n^2).
  • KMP / Z-Algorithm / Rolling Hash β€” Pattern matching in O(n+m)O(n + m).
  • Stack β€” Balanced parens, decode strings, simplify path.

⚠️ Common Pitfalls​

  • C#: avoid string += in a loop β€” use StringBuilder.
  • Char range assumption (a..z vs full Unicode). Clarify before coding.
  • Off-by-one when comparing two pointers i < j in palindrome expansion.

πŸ“š Study Resources​

πŸ“Ί Videos​

πŸ“– Books​

  • Cracking the Coding Interview β€” Ch. 1 (Arrays & Strings)
  • Algorithms β€” Sedgewick & Wayne β€” Ch. 5 (Strings)

🌐 Articles & References​


πŸ’» All Strings Problems​