🚀 Phases 1–5 are live — Days 1–17 cover the foundations and the algorithmic patterns. See the roadmap →
Day 27 - Advanced StringsPractice QuestionsOverview

Advanced Strings Practice Questions

Ten interview problems, every algorithm in the chapter represented. The easy problems are direct applications; the hard ones require combining multiple techniques — if you’re solving them correctly, you’ve genuinely internalized the material.

Before reading any solution, ask yourself:

  1. Is this a “find pattern in text” problem? → try KMP or Z-algorithm.
  2. Does it involve duplicate / repeated substrings of a specific length? → try Rabin-Karp rolling hash.
  3. Does it involve palindromes? → expand-around-center for O(n²), Manacher’s for O(n).
  4. Does it involve a sliding window with character frequencies? → two-pointer + frequency array.

The code follows from the right framing.

Easy

ProblemPatternStatus
Implement strStrKMP or naiveAvailable
Repeated Substring PatternKMP failure function — period detectionAvailable

Medium

ProblemPatternStatus
Longest Happy PrefixKMP failure function directlyAvailable
Find All Anagrams in a StringSliding window + frequency arrayAvailable
Minimum Window SubstringSliding window + two-pointerAvailable
Longest Palindromic SubstringExpand around center / Manacher’sAvailable
Count and SayString simulation / run-length encodingAvailable

Hard

ProblemPatternStatus
Shortest PalindromeKMP on s + '#' + reverse(s)Available
Longest Duplicate SubstringBinary search + Rabin-Karp rolling hashAvailable
Wildcard MatchingDP (2D) or greedy two-pointerAvailable

More Practice (Coming Soon)

ProblemPatternStatus
Word Search IITrie + DFS (Aho-Corasick flavor)Coming Soon
Edit DistanceClassic 2D DPComing Soon
Regular Expression MatchingDP with wildcard semanticsComing Soon
Distinct Subsequences2D DPComing Soon
Text JustificationString simulationComing Soon
Scramble StringInterval DPComing Soon
Palindrome PairsTrie + KMPComing Soon
Count Palindromic SubstringsManacher’s or expandComing Soon
String to Integer (atoi)Careful parsingComing Soon
Decode Ways1D DP on digitsComing Soon