Pattern #3

Strings

Important interview questions, thinking patterns, and rules for solving string problems in Go.

Must Solve

17 core questions — solve these first.

  1. 1.Valid Anagram
    easy
  2. 2.Valid Palindrome
    easy
  3. 3.Longest Common Prefix
    easy
  4. 4.First Unique Character in a String
    easy
  5. 5.Reverse String
    easy
  6. 6.Reverse Words in a String
    medium
  7. 7.Longest Substring Without Repeating Characters
    medium
  8. 8.Group Anagrams
    medium
  9. 9.Valid Parentheses
    easy
  10. 10.String to Integer (atoi)
    medium
  11. 11.Find the Index of the First Occurrence in a String
    easy
  12. 12.Longest Palindromic Substring
    medium
  13. 13.Palindromic Substrings
    medium
  14. 14.Minimum Window Substring
    hard
  15. 15.Decode String
    medium
  16. 16.Multiply Strings
    medium
  17. 17.Roman to Integer
    easy

Also Important

13 more questions worth practicing.

  1. 18.Isomorphic Strings
    easy
  2. 19.Word Pattern
    easy
  3. 20.Ransom Note
    easy
  4. 21.Add Strings
    easy
  5. 22.Compare Version Numbers
    medium
  6. 23.Zigzag Conversion
    medium
  7. 24.String Compression
    medium
  8. 25.Repeated Substring Pattern
    easy
  9. 26.Encode and Decode Strings
    medium
  10. 27.Longest Repeating Character Replacement
    medium
  11. 28.Permutation in String
    medium
  12. 29.Find All Anagrams in a String
    medium
  13. 30.Valid Palindrome II
    easy

How to Think

  1. Need character count?Hash Map / Frequency Array
  2. Need compare two strings?Frequency / Two Pointers
  3. Need longest substring?Sliding Window
  4. Need substring without duplicate?Sliding Window + Hash Set/Map
  5. Need smallest valid substring?Sliding Window
  6. Need palindrome?Two Pointers / Expand from Center
  7. Need group same characters?Sort string / Frequency signature
  8. Need brackets validation?Stack
  9. Need find pattern inside string?Two Pointers / KMP
  10. Only lowercase a-z?[26]int
  11. Need build result many times?strings.Builder (avoid concat)

Interview Rules

  1. 1. Ask: case-sensitive or not?
  2. 2. Ask: spaces/symbols matter?
  3. 3. Check empty string.
  4. 4. Check one character.
  5. 5. Check repeated characters.
  6. 6. Check uppercase/lowercase.
  7. 7. Know: substring = continuous
  8. 8. Know: subsequence = not necessarily continuous
  9. 9. Try to reduce O(n²) substring checks using Sliding Window.
  10. 10. In Go: strings are byte sequences; Unicode may need []rune.

💡 Strings are the 2nd most common interview topic. Master these 30 problems and you cover most string questions.