Basic String Problems for Coding Interviews
214 basic String problems from real coding interviews, each with test cases you can run online. By difficulty they split into 214 basic, 0 intermediate and 0 advanced. The companies that ask them most often are Google, Amazon, Meta, Microsoft.
Solve a few problems of each level, name the pattern after each one and revisit the ones that needed a hint a week later. Practise stating the time and space complexity and the edge cases before you code.
Coding problems
- Valid Parentheses (Basic)
- Reverse String (Basic)
- First Unique Character (Basic)
- Valid Palindrome (Basic)
- Valid Anagram (Basic)
- Ransom Note (Basic)
- Count Vowels (Basic)
- Caesar Cipher (Basic)
- Run-Length Encoding (Basic)
- Largest Odd Prefix (Basic)
- Reverse Words in a String (Basic)
- Rotate String Check (Basic)
- Reverse Vowels of a String (Basic)
- Excel Column Number (Basic)
- Add Binary (Basic)
- Common Prefix of Two Strings (Basic)
- Length of Last Word (Basic)
- Count Words (Basic)
- Balanced String Split (Basic)
- Longest Palindrome From Letters (Basic)
- Reverse Prefix Up To a Letter (Basic)
- Remove Outer Parentheses (Basic)
- Single Row Keyboard Typing Time (Basic)
- Find the Added Letter (Basic)
- Next Greatest Letter (Basic)
- Maximum Number of Balloons (Basic)
- Halves Are Alike (Basic)
- Is Subsequence (Basic)
- Count Asterisks Outside Bars (Basic)
- Largest Triple of Equal Digits (Basic)
- Reverse Every Other Chunk (Basic)
- Remove Adjacent Duplicate Letters (Basic)
- Restore a Shuffled String (Basic)
- Minimum Adjacent Swaps for Palindrome (Basic)
- Isomorphic Strings (Basic)
- Rotate String (Basic)
- Length of Last Word (Basic)
- Add Strings (Basic)
- Generate Balanced Bracket Types (Basic)
- Find All Shortest Transformation Paths (Basic)
- Minimum Operations on Binary String (Basic)
- CSV Parser (Basic)
- Boolean Parenthesization Count (Basic)
- Palindrome Linked List (Basic)
- Level Order Traversal (Basic)
- Bottom-Up Level Order (Basic)
- Count Sorted Vowel Strings (Basic)
- Find First Occurrence (Basic)
- String Compression (Basic)
- Custom Sort String (Basic)
- Count Binary Substrings (Basic)
- Goat Latin (Basic)
- Positions of Large Groups (Basic)
- Minimum Steps to Make Two Strings Anagram (Basic)
- Partition String Into Unique Substrings (Basic)
- Baseball Game (Basic)
- Minimum Add to Make Parentheses Valid (Basic)
- Shortest Word Distance (Basic)
- Valid Palindrome With One Deletion (Basic)
- Backspace String Compare (Basic)
- Long Pressed Name (Basic)
- Letter Case Permutation (Basic)
- Logger Rate Limiter (Basic)
- Elias Gamma Encoding (Basic)
- Find Words Formed by Characters (Basic)
- Check If Two String Arrays Are Equivalent (Basic)
- Maximum Words in Sentences (Basic)
- Number of Different Integers in a String (Basic)
- Truncate Sentence (Basic)
- Detect Capital (Basic)
- Largest Substring Between Two Equal Characters (Basic)
- Count the Number of Consistent Strings (Basic)
- Count Pairs of Similar Strings (Basic)
- Second Largest Digit in a String (Basic)
- Check if the Sentence Is Pangram (Basic)
- Goal Parser Interpretation (Basic)
- Number of Strings That Appear as Substrings in Word (Basic)
- Prefix Sums of a Linked List (Basic)
- Construct String From Binary Tree (Basic)
- One Edit Distance (Basic)
Related
Frequently asked questions
How do I get good at string problems?
Practise by level, name the pattern after you solve each problem and review the ones you needed hints for. The list is ordered so you can start with the basic ones.
Can I run string problems online here?
Yes. Each problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and more.