๐Ÿ“‘ Table of Contents

  1. ๐Ÿ“˜ DSA: Strings Learning Roadmap (Beginner โ†’ Advanced) 1.1. 1. Basics of Strings (Foundations) 1.2. ๐Ÿ” 2. Two Pointers on Strings 1.3. ๐ŸชŸ 3. Sliding Window (Very Important) 1.4. ๐Ÿงฎ 4. Hashing for Strings 1.5. ๐Ÿ”ค 5. Pattern Matching Algorithms 1.6. 6. Advanced String Topics
  2. ๐Ÿ“ Must Do String Problems 2.1. ๐Ÿ”น Level 1 โ€“ Easy 2.2. ๐Ÿ”น Level 2 โ€“ Medium 2.3. ๐Ÿ”น Level 3 โ€“ Hard

๐ŸŽฏ Main Topics Covered

  1. 1 Basics of Strings Foundations
  2. 2 Two Pointers on Strings
  3. 3 Sliding Window Very Important
  4. 4 Hashing for Strings
  5. 5 Pattern Matching Algorithms
  6. img src assetsiconspuzzlesvg relative_url classinline-icon alt 6 Advanced String Topics
  7. Level 1 Easy
  8. Level 2 Medium โ€ฆ and 1 more

๐Ÿ“˜ DSA: Strings Learning Roadmap (Beginner โ†’ Advanced)

1. Basics of Strings (Foundations)

These are must-know before solving problems.

  • Mutable vs Immutable (C++: std::string is mutable)

  • Character arrays vs string class

  • Common operations: length, substring, concatenation, comparison

  • ASCII & Unicode basics

-> Click here for more details

๐Ÿ” 2. Two Pointers on Strings

Used for many interview problems (palindrome, substring checks).

Key patterns:

  • Move pointers from left & right

  • Shrink/expand window on conditions

๐ŸชŸ 3. Sliding Window (Very Important)

Strings + Sliding Window = 20% of interview questions.

Understand two types:

๐Ÿ”ธ Fixed Window

E.g., find anagrams of a pattern.

๐Ÿ”ธ Variable Window

E.g., longest substring with K distinct characters.

๐Ÿงฎ 4. Hashing for Strings

Character frequency arrays

  • For lowercase โ†’ size 26

  • For ASCII โ†’ size 256

  • For Unicode โ†’ use hash maps

Rolling Hash / Rabin-Karp

  • Efficient substring search

  • Used for detecting duplicate substrings, plagiarism, etc.

Interview problems:

  • Rabin-Karp implementation

  • Longest duplicate substring (binary search + rolling hash)

๐Ÿ”ค 5. Pattern Matching Algorithms

KMP (Knuthโ€“Morrisโ€“Pratt)

Why important?

  • Used for substring search in O(n + m)

  • LPS array is commonly asked in interviews.

Z-Algorithm

  • Alternate fast pattern matching

  • Helps in string prefix-based problems

Trie (String Tree)

  • Useful for autocomplete, prefix search, dictionary problems

Problems:

  • Word search

  • Longest common prefix

  • Implement Trie

6. Advanced String Topics

These help in elite interviews.

Suffix Array

  • Used for lexicographical ordering of suffixes

  • Applications: substring search, LCP computation

Suffix Tree / Compressed Trie

  • Extremely fast substring search

  • Rare but high-reward for deep interviews

Manacherโ€™s Algorithm

  • O(n) longest palindromic substring

๐Ÿ“ Must Do String Problems

๐Ÿ”น Level 1 โ€“ Easy

  1. Reverse string

  2. Palindrome check

  3. Count occurrences of characters

  4. Remove duplicates

  5. String compression

  6. Leetcode 412. Fizz Buzz - Solution

  7. Leetcode 14. Longest Common Prefix - Solution

๐Ÿ”น Level 2 โ€“ Medium

  1. Longest substring without repeating

  2. Longest palindromic substring

  3. Group anagrams

  4. Valid parentheses

  5. Multiply large numbers (string simulation)

  6. Leetcode 271. Encode and Decode Strings{Premium Problem} - My Leetcode Solution link

  7. Leetcode 647. Palindromic Substrings - My Leetcode Solution link

  8. Leetcode 5. Longest Palindromic Substring - My Leetcode Solution link

๐Ÿ”น Level 3 โ€“ Hard

  1. Minimum window substring

  2. Word break (DP + String)

  3. Regular expression matching (DP)

  4. Wildcard matching

  5. KMP + Z-algorithm applications

  6. Longest duplicate substring (binary search + hash)

  7. Leetcode 647. Palindromic Substrings - My Leetcode Solution link

  8. Leetcode 68. Text Justification - My Leetcode Solution link