String
181 problems · 127 with full explanations
44 Easy63 Medium21 Hard
String problems range from simple character counting to complex pattern matching. Common approaches include two pointers, sliding window, prefix hashing, and the KMP algorithm. In C#, strings are immutable — use StringBuilder for efficient concatenation inside loops.
How to practice
To practice String problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the string pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.
Start here (Easy + explained)
All String problems
- 12.Integer to RomanMedium
- 13.Roman to IntegerEasy
- 14.Longest Common PrefixEasy
- 22.Generate ParenthesesMedium
- 30.Substring with Concatenation of All WordsHard
- 32.Longest Valid ParenthesesHard
- 38.Count and SayMedium
- 44.Wildcard MatchingHard
- 58.Length of Last WordEasy
- 67.Add BinaryEasy
- 68.Text JustificationHard
- 76.Minimum Window SubstringHard
- 87.Scramble StringHard
- 126.Word Ladder IIHard
- 165.Compare Version NumbersMedium
- 166.Fraction to Recurring DecimalMedium
- 171.Excel Sheet Column NumberEasy
- 179.Largest NumberMedium
- 212.Word Search IIHard
- 214.Shortest PalindromeHard
- 241.Different Ways to Add ParenthesesMedium
- 257.Binary Tree PathsEasy
- 273.Integer to English WordsHard
- 299.Bulls and CowsUnknown
- 316.Remove Duplicate LettersMedium
- 331.Verify Preorder Serialization of a Binary TreeUnknown
- 344.Reverse StringEasy
- 467.Unique Substrings in Wraparound StringMedium
- 474.Ones and ZeroesMedium
- 500.Keyboard RowEasy
- 539.Minimum Time DifferenceMedium
- 564.Find the Closest PalindromeHard
- 567.Permutation in StringMedium
- 592.Fraction Addition and SubtractionUnknown
- 657.Robot Return to OriginUnknown
- 664.Strange PrinterHard
- 678.Valid Parenthesis StringMedium
- 696.Count Binary SubstringsEasy
- 709.To Lower CaseEasy
- 712.Minimum ASCII Delete Sum for Two StringsMedium
- 726.Number of AtomsHard
- 761.Special Binary StringUnknown
- 763.Partition LabelsMedium
- 784.Letter Case PermutationMedium
- 796.Rotate StringEasy
- 820.Short Encoding of WordsMedium
- 821.Shortest Distance to a CharacterEasy
- 838.Push DominoesMedium
- 839.Similar String GroupsHard
- 856.Score of ParenthesesMedium
- 880.Decoded String at IndexMedium
- 884.Uncommon Words from Two SentencesEasy
- 890.Find and Replace PatternMedium
- 902.Numbers At Most N Given Digit SetHard
- 916.Word SubsetsMedium
- 917.Reverse Only LettersEasy
- 921.Minimum Add to Make Parentheses ValidMedium
- 944.Delete Columns to Make SortedEasy
- 955.Delete Columns to Make Sorted IIMedium
- 960.Delete Columns to Make Sorted IIIHard
- 966.Vowel SpellcheckerMedium
- 981.Time Based Key-Value StoreMedium
- 1028.Recover a Tree From Preorder TraversalHard
- 1061.Lexicographically Smallest Equivalent StringMedium
- 1079.Letter Tile PossibilitiesMedium
- 1081.Smallest Subsequence of Distinct CharactersMedium
- 1092.Shortest Common SupersequenceHard
- 1106.Parsing A Boolean ExpressionHard
- 1190.Reverse Substrings Between Each Pair of ParenthesesMedium
- 1233.Remove Sub-Folders from the FilesystemMedium
- 1358.Number of Substrings Containing All Three CharactersMedium
- 1371.Find the Longest Substring Containing Vowels in Even CountsMedium
- 1392.Longest Happy PrefixUnknown
- 1400.Construct K Palindrome StringsUnknown
- 1405.Longest Happy StringUnknown
- 1408.String Matching in an ArrayUnknown
- 1410.HTML Entity ParserUnknown
- 1415.The k-th Lexicographical String of All Happy Strings of Length nUnknown
- 1422.Maximum Score After Splitting a StringUnknown
- 1455.Check If a Word Occurs As a Prefix of Any Word in a SentenceUnknown
- 1461.Check If a String Contains All Binary Codes of Size KMedium
- 1487.Making File Names UniqueUnknown
- 1513.Number of Substrings With Only 1sUnknown
- 1529.Minimum Suffix FlipsUnknown
- 1545.Find Kth Bit in Nth Binary StringEasy
- 1573.Number of Ways to Split a StringUnknown
- 1578.Minimum Time to Make Rope ColorfulMedium
- 1593.Split a String Into the Max Number of Unique SubstringsMedium
- 1598.Crawler Log FolderEasy
- 1625.Lexicographically Smallest String After Applying OperationsUnknown
- 1639.Number of Ways to Form a Target String Given a DictionaryHard
- 1653.Minimum Deletions to Make String BalancedMedium
- 1678.Goal Parser InterpretationUnknown
- 1684.Count the Number of Consistent StringsEasy
- 1689.Partitioning Into Minimum Number Of Deci-Binary NumbersMedium
- 1717.Maximum Score From Removing SubstringsUnknown
- 1758.Minimum Changes To Make Alternating Binary StringUnknown
- 1763.Longest Nice SubstringEasy
- 1768.Merge Strings AlternatelyEasy
- 1769.Minimum Number of Operations to Move All Balls to Each BoxMedium
- 1784.Check if Binary String Has at Most One Segment of OnesUnknown
- 1790.Check if One String Swap Can Make Strings EqualEasy
- 1813.Sentence Similarity IIIUnknown
- 1844.Replace All Digits with CharactersEasy
- 1859.Sorting the SentenceUnknown
- 1888.Minimum Number of Flips to Make the Binary String AlternatingUnknown
- 1910.Remove All Occurrences of a SubstringUnknown
- 1930.Unique Length-3 Palindromic SubsequencesMedium
- 1935.Maximum Number of Words You Can TypeUnknown
- 1945.Sum of Digits of String After ConvertUnknown
- 1948.Delete Duplicate Folders in SystemUnknown
- 1957.Delete Characters to Make Fancy StringUnknown
- 1963.Minimum Number of Swaps to Make the String BalancedUnknown
- 1967.Number of Strings That Appear as Substrings in WordUnknown
- 1980.Find Unique Binary StringMedium
- 2011.Final Value of Variable After Performing OperationsUnknown
- 2014.Longest Subsequence Repeated k TimesUnknown
- 2053.Kth Distinct String in an ArrayUnknown
- 2096.Step-By-Step Directions From a Binary Tree Node to AnotherMedium
- 2109.Adding Spaces to a StringEasy
- 2116.Check if a Parentheses String Can Be ValidMedium
- 2131.Longest Palindrome by Concatenating Two Letter WordsMedium
- 2138.Divide a String Into Groups of Size kUnknown
- 2182.Construct String With Repeat LimitMedium
- 2185.Counting Words With a Given PrefixEasy
- 2264.Largest 3-Same-Digit Number in StringEasy
- 2273.Find Resultant Array After Removing AnagramsUnknown
- 2337.Move Pieces to Obtain a StringMedium
- 2375.Construct Smallest Number From DI StringMedium
- 2379.Minimum Recolors to Get K Consecutive Black BlocksEasy
- 2416.Sum of Prefix Scores of StringsHard
- 2418.Sort the PeopleEasy
- 2434.Using a Robot to Print the Lexicographically Smallest StringMedium
- 2490.Circular SentenceEasy
- 2516.Take K of Each Character From Left and RightMedium
- 2559.Count Vowel Strings in RangesMedium
- 2573.Find the String with LCPUnknown
- 2609.Find the Longest Balanced Substring of a Binary StringEasy
- 2645.Minimum Additions to Make Valid StringMedium
- 2678.Number of Senior CitizensEasy
- 2696.Minimum String Length After Removing SubstringsEasy
- 2707.Extra Characters in a StringMedium
- 2785.Sort Vowels in a StringMedium
- 2825.Make String a Subsequence Using Cyclic IncrementsMedium
- 2839.Check if Strings Can be Made Equal With Operations IEasy
- 2840.Check if Strings Can be Made Equal With Operations IIMedium
- 2900.Longest Unequal Adjacent Groups Subsequence IEasy
- 2901.Longest Unequal Adjacent Groups Subsequence IIUnknown
- 2914.Minimum Number of Changes to Make Binary String BeautifulEasy
- 2930.Number of Strings Which Can Be Rearranged to Contain SubstringMedium
- 2942.Find Words Containing CharacterEasy
- 2976.Minimum Cost to Convert String IMedium
- 2977.Minimum Cost to Convert String IIUnknown
- 2981.Find Longest Special Substring That Occurs Thrice IMedium
- 2999.Count the Number of Powerful IntegersUnknown
- 3003.Maximize the Number of Partitions After OperationsUnknown
- 3016.Minimum Number of Pushes to Type Word IIMedium
- 3042.Count Prefix and Suffix Pairs IEasy
- 3043.Find the Length of the Longest Common PrefixEasy
- 3085.Minimum Deletions to Make String K-SpecialEasy
- 3136.Valid WordEasy
- 3163.String Compression IIIUnknown
- 3170.Lexicographically Minimum String After Removing StarsUnknown
- 3174.Clear DigitsEasy
- 3223.Minimum Length of String After OperationsUnknown
- 3227.Vowels Game in a StringUnknown
- 3234.Count the Number of Substrings With Dominant OnesEasy
- 3306.Count of Substrings Containing Every Vowel and K Consonants IIMedium
- 3330.Find the Original Typed String IEasy
- 3333.Find the Original Typed String IIUnknown
- 3335.Total Characters in String After Transformations IMedium
- 3337.Total Characters in String After Transformations IIUnknown
- 3403.Find the Lexicographically Largest String From the Box IUnknown
- 3442.Maximum Difference Between Even and Odd Frequency IMedium
- 3445.Maximum Difference Between Even and Odd Frequency IIMedium
- 3461.Check If Digits Are Equal in String After Operations IEasy
- 3474.Lexicographically Smallest Generated StringEasy
- 3541.Find Most Frequent Vowel and ConsonantUnknown
- 3606.Coupon Code ValidatorUnknown
- 3713.Longest Balanced Substring IUnknown
- 3714.Longest Balanced Substring IIUnknown