Pattern
String
A compact view of archive entries grouped by recurring technique.
204 entries
204 entries tagged as String.
15.04.2026
easy2515. Shortest Distance to Target String in a Circular Array
Distance to target
12.04.2026
hard1320. Minimum Distance to Type a Word Using Two Fingers
Min travel on keyboard to type a word
04.04.2026
medium2075. Decode the Slanted Ciphertext
Decode row-encoded string
31.03.2026
hard3474. Lexicographically Smallest Generated String
String from pattern matches
28.03.2026
hard2573. Find the String with LCP
Build string from longest common prefixes matrix
14.03.2026
medium1415. The k-th Lexicographical String of All Happy Strings of Length n
K-th generated abc non-repeating string
08.03.2026
medium1980. Find Unique Binary String
Uniq bits not in a set
06.03.2026
easy1784. Check if Binary String Has at Most One Segment of Ones
+0 pattern
05.03.2026
easy1758. Minimum Changes To Make Alternating Binary String
Min flips to make bits alterating
03.03.2026
medium1545. Find Kth Bit in Nth Binary String
Kth bit in s=s+1+inv(rev(s)) sequence
27.02.2026
hard3666. Minimum Operations to Equalize Binary String
Min steps to convert 01 stirng to ones flipping K
23.02.2026
medium1461. Check If a String Contains All Binary Codes of Size K
All numbers as substring length of k window
22.02.2026
easy868. Binary Gap
Distance between onces in a binary
20.02.2026
hard761. Special Binary String
Swaps of 1M0-special substring to make string large
13.02.2026
medium3714. Longest Balanced Substring II
Largest equal frequencies substring of abc-string
12.02.2026
medium3713. Longest Balanced Substring I
Max substring with equal frequencies window
07.02.2026
medium1653. Minimum Deletions to Make String Balanced
Min removal to balance 'ab'
30.01.2026
hard2977. Minimum Cost to Convert String II
Min cost to convert string with transitions of substrings
29.01.2026
medium2976. Minimum Cost to Convert String I
Min cost to convert string
10.01.2026
medium712. Minimum ASCII Delete Sum for Two Strings
Min removed sum to make strings equal
11.11.2025
medium474. Ones and Zeroes
Longest subsequence (ones,zeros) at most (m,n)
23.10.2025
easy3461. Check If Digits Are Equal in String After Operations I
Fold each pair to (a+b)%10 until 2 left
19.10.2025
medium1625. Lexicographically Smallest String After Applying Operations
Min string after shifting by b and rotating odd indice by a
13.10.2025
medium2273. Find Resultant Array After Removing Anagrams
Dedup anagrams
24.09.2025
medium166. Fraction to Recurring Decimal
Calc a/b to string x.y(z)
12.09.2025
medium3227. Vowels Game in a String
Can Alice win Bob both removeing odd-even vowel count substring optimally
11.09.2025
medium2785. Sort Vowels in a String
Sort vowels
14.08.2025
easy2264. Largest 3-Same-Digit Number in String
Max 3-digit in string
21.07.2025
easy1957. Delete Characters to Make Fancy String
No three chars repeats
4.07.2025
hard3307. Find the K-th Character in String Game II
kth char in double+shift by ops[i] string manipulation
3.07.2025
easy3304. Find the K-th Character in String Game I
kth char after appending rotated self
2.07.2025
hard3333. Find the Original Typed String II
ways to remove duplicates, preserve length at least k
23.06.2025
hard2081. Sum of k-Mirror Numbers
n palindromes in both 10 and k-base
22.06.2025
easy2138. Divide a String Into Groups of Size k
k-chunked string, filled tail
21.06.2025
medium3085. Minimum Deletions to Make String K-Special
Min remove to make frequencies k-narrow
07.06.2025
medium3170. Lexicographically Minimum String After Removing Stars
Smallest string by remove min to the left of
06.06.2025
medium2434. Using a Robot to Print the Lexicographically Smallest String
Smallest string by writing to stack
05.06.2025
medium1061. Lexicographically Smallest Equivalent String
Map by smallest in group from associate s1 with s2
04.06.2025
medium3403. Find the Lexicographically Largest String From the Box I
Max string of every split by n
25.05.2025
medium2131. Longest Palindrome by Concatenating Two Letter Words
Max palindrome length from 2 char words
14.05.2025
hard3337. Total Characters in String After Transformations II
t steps to convert char into next nums[c] chars
13.05.2025
medium3335. Total Characters in String After Transformations I
String length after t shifts c=c+1,z=ab
18.04.2025
medium38. Count and Say
nth run-length encoded string
30.03.2025
medium763. Partition Labels
Split string into separate chars sets
10.03.2025
medium3306. Count of Substrings Containing Every Vowel and K Consonants II
Substring with all vowels and k others pointers
28.02.2025
hard1092. Shortest Common Supersequence
Shortest string with both subsequences
22.02.2025
hard1028. Recover a Tree From Preorder Traversal
Recover binary tree from depth-dashes string
18.02.2025
medium2375. Construct Smallest Number From DI String
Smallest number from 1..9 and Inc-Dec pattern
15.02.2025
medium2698. Find the Punishment Number of an Integer
Sum x^2 if it's string partition sum = x
11.02.2025
medium1910. Remove All Occurrences of a Substring
Remove substring recursively
10.02.2025
easy3174. Clear Digits
Remove [char][digit] pairs from string
05.02.2025
easy1790. Check if One String Swap Can Make Strings Equal
One swap to make stings equal
13.01.2025
medium3223. Minimum Length of String After Operations
Length after removing repeatings > 2
12.01.2025
medium2116. Check if a Parentheses String Can Be Valid
Balance parenthesis with wildcards
11.01.2025
medium1400. Construct K Palindrome Strings
Can make k palindromes from string?
10.01.2025
medium916. Word Subsets
Words containing all chars of words2
08.01.2025
easy3042. Count Prefix and Suffix Pairs I
Count prefix-suffix matched pairs
07.01.2025
easy1408. String Matching in an Array
All substrings
05.01.2025
medium2381. Shifting Letters II
Apply from..to, direction shifts to string chars sweep
01.01.2025
easy1422. Maximum Score After Splitting a String
Max(left zeros + right ones)
30.12.2024
medium2466. Count Ways To Build Good Strings
Ways to make 01-string length of low..high programming
29.12.2024
hard1639. Number of Ways to Form a Target String Given a Dictionary
Ways to make target with increasing positions in words programming
17.12.2024
medium2182. Construct String With Repeat Limit
Max lexical ordered with repeat limit string sort
05.12.2024
medium2337. Move Pieces to Obtain a String
Move L left and R right to match strings
04.12.2024
medium2825. Make String a Subsequence Using Cyclic Increments
Increase some chars once to make a subsequence
03.12.2024
medium2109. Adding Spaces to a String
Insert spaces into string
02.12.2024
easy1455. Check If a Word Occurs As a Prefix of Any Word in a Sentence
Position of the prefix
05.11.2024
medium2914. Minimum Number of Changes to Make Binary String Beautiful
Min changes to make even-sized 0 and 1
04.11.2024
medium3163. String Compression III
Compress repeating chars in string pointers
03.11.2024
easy796. Rotate String
Is string rotated goal?
01.11.2024
easy1957. Delete Characters to Make Fancy String
Filter 3+ repeating chars from string
25.10.2024
medium1233. Remove Sub-Folders from the Filesystem
Remove empty subfolders
21.10.2024
medium1593. Split a String Into the Max Number of Unique Substrings
Max count of unique split parts
19.10.2024
medium1545. Find Kth Bit in Nth Binary String
kth bit of sequence bs[i] = bs[i-1] + '1' + rev(inv(bs[i-1])) manipulation
15.10.2024
medium2938. Separate Black and White Balls
Min moves to sort 01 string
08.10.2024
medium1963. Minimum Number of Swaps to Make the String Balanced
Min swaps to balance brackets pointers
07.10.2024
easy2696. Minimum String Length After Removing Substrings
Remove 'AB' and 'CD' from the string
06.10.2024
medium1813. Sentence Similarity III
Are strings equal after inserting substring?
05.10.2024
medium567. Permutation in String
Is s2 contains permutation of s1? pointers
23.09.2024
hard2707. Extra Characters in a String
Min extra chars to form an s from dictionary programming
20.09.2024
hard214. Shortest Palindrome
Prepend to make the shortest palindrome hash
15.09.2024
medium1371. Find the Longest Substring Containing Vowels in Even Counts
Longest substring with even number of "aeiou" manipulation pointers
03.09.2024
easy1945. Sum of Digits of String After Convert
Sum of number chars k times
24.08.2024
hard564. Find the Closest Palindrome
Closest palindrome number
23.08.2024
easy592. Fraction Addition and Subtraction
Eval string of fractions sum
21.08.2024
hard664. Strange Printer
Minimum continuous replacements to make a string programming
06.08.2024
medium3016. Minimum Number of Pushes to Type Word II
Minimum keystrokes after assigning letter to keys
05.08.2024
easy2053. Kth Distinct String in an Array
kth unique
01.08.2024
easy2678. Number of Senior Citizens
Count filtered by a substring
30.07.2024
medium1653. Minimum Deletions to Make String Balanced
Min removals to sort 'ab' string
27.07.2024
medium2976. Minimum Cost to Convert String I
Min cost to change the source to the target
16.07.2024
medium2096. Step-By-Step Directions From a Binary Tree Node to Another
U-L-R path from s to d in a Binary Tree
11.07.2024
medium1190. Reverse Substrings Between Each Pair of Parentheses
Reverse string in parentheses recursively
07.06.2024
medium648. Replace Words
Replace words with suffixes from dictionary
04.06.2024
easy409. Longest Palindrome
Max palindrome length from chars
03.06.2024
medium2486. Append Characters to String to Make Subsequence
Min diff to make t substring of s
02.06.2024
easy344. Reverse String
Reverse an array
01.06.2024
easy3110. Score of a String
Sum(abs(window))
29.05.2024
medium1404. Number of Steps to Reduce a Number in Binary Representation to One
Steps even/2, odd+1 to make binary s to 1
28.05.2024
medium1208. Get Equal Substrings Within Budget
Max substring sum(abs(s[..] - t[..])) < maxCost window
01.05.2024
easy2000. Reverse Prefix of Word
Reverse [..ch] prefix in string
17.04.2024
medium988. Smallest String Starting From Leaf
Smallest string from leaf to root in a Binary Tree
07.04.2024
medium678. Valid Parenthesis String
Are parenthesis valid with wildcard?
05.04.2024
easy1544. Make The String Great
Remove lowercase-uppercase pairs
03.04.2024
medium79. Word Search
Does grid have a word path?
02.04.2024
easy205. Isomorphic Strings
Can map chars from one string to another?
01.04.2024
easy58. Length of Last Word
Last word length
22.03.2024
easy234. Palindrome Linked List
Is Linked List a palindrome
11.03.2024
medium791. Custom Sort String
Construct string from s using order
05.03.2024
medium1750. Minimum Length of String After Deleting Similar Ends
Min length after trimming matching prefix-suffix several times.
01.03.2024
easy2864. Maximum Odd Binary Number
Max odd number string rearrangement.
13.02.2024
easy2108. Find First Palindromic String in the Array
Find a palindrome.
10.02.2024
medium647. Palindromic Substrings
Count palindromes substrings.
07.02.2024
medium451. Sort Characters By Frequency
Sort string by char's frequencies.
05.02.2024
easy387. First Unique Character in a String
First non-repeating char position.
04.02.2024
hard76. Minimum Window Substring
Let's try to shorten the code
24.01.2024
medium1457. Pseudo-Palindromic Paths in a Binary Tree
Count can-form-a-palindrome paths root-leaf in a binary tree.
23.01.2024
medium1239. Maximum Length of a Concatenated String with Unique Characters
Max length subsequence of strings array with unique chars.
13.01.2024
medium1347. Minimum Number of Steps to Make Two Strings Anagram
Min operations to make string t anagram of s.
12.01.2024
easy1704. Determine if String Halves Are Alike
Let's use some Kotlin's API
31.12.2023
easy1624. Largest Substring Between Two Equal Characters
Max distance between same chars in string.
28.12.2023
hard1531. String Compression II
Min length of run-length encoded aabcc -> a2bc3 after deleting at most k characters
25.12.2023
medium91. Decode Ways
Ways to decode back 'A' -> '1', 'B' -> '2' … 'Z' -> '26'
24.12.2023
easy1758. Minimum Changes To Make Alternating Binary String
In a stressfull situation better to just use 4 counters: oddOnes, evenOnes, oddZeros, evenZeros. Then do something with them.
23.12.2023
easy1496. Path Crossing
Is path string of 'N', 'E', 'W', 'S' crosses
22.12.2023
easy1422. Maximum Score After Splitting a String
Max left zeros + right ones in 01-array
08.12.2023
easy606. Construct String from Binary Tree
Pre-order binary tree serialization
07.12.2023
easy1903. Largest Odd Number in String
Largest odd number in a string
04.12.2023
easy2264. Largest 3-Same-Digit Number in String
Largest 3-same-digit number in a string
01.12.2023
easy1662. Check If Two String Arrays are Equivalent
Two dimensional array equals
28.11.2023
hard2147. Number of Ways to Divide a Long Corridor
Count ways to place borders separating pairs of 'S' in 'SP' string
16.11.2023
medium1980. Find Unique Binary String
First absent number in a binary string array
14.11.2023
medium1930. Unique Length-3 Palindromic Subsequences
Count of unique palindrome substrings of length 3
13.11.2023
medium2785. Sort Vowels in a String
Sort vowels in a string
03.11.2023
medium767. Reorganize String
Non-repeating consequent chars string from another string
27.10.2023
medium5. Longest Palindromic Substring
Longest palindrome substring
19.10.2023
medium844. Backspace String Compare
Remove all of the backspaced chars before comparing
1.10.2023
easy557. Reverse Words in a String III
Reverse words
27.09.2023
medium880. Decoded String at Index
k-th character in an encoded string like a3b2=aaabaaab
23.09.2023
medium1048. Longest String Chain
Longest chain of words with single character added
22.09.2023
easy392. Is Subsequence
Is string a subsequence of another
12.09.2023
medium1647. Minimum Deletions to Make Character Frequencies Unique
Minimum removes duplicate frequency chars from string
2.09.2023
medium2707. Extra Characters in a String
Min count of leftovers after string split by the dictionary
25.08.2023
medium97. Interleaving String
Can a string be a merge of two other strings
24.08.2023
hard68. Text Justification
Spread words to lines, evenly spacing left->right, and left-spacing the last line
22.08.2023
easy168. Excel Sheet Column Title
Excel col number to letter-number 1 -> A, 28 -> AB
21.08.2023
easy459. Repeated Substring Pattern
careful to not shift by whole length
04.08.2023
medium139. Word Break
If a word is a wordDict concatenation
30.07.2023
hard664. Strange Printer
Minimum continuous overrides by the same character to make a string
10.07.2023
hard2272. Substring With Largest Variance
Max diff between count s[i] and count s[j] in all substrings of s
3.07.2023
easy859. Buddy Strings
Is it just one swap s[i]<>s[j] to string s == string goal
13.05.2023
medium2466. Count Ways To Build Good Strings
Let's write a DFS solution, adding zero or one and count the good strings.
5.05.2023
medium1456. Maximum Number of Vowels in a Substring of Given Length
we can use Set to check if it is a vowel
4.05.2023
medium649. Dota2 Senate
Use Queue and count how many bans are from the Radiant and from the Dire.
28.04.2023
hard839. Similar String Groups
decrease the groups when the two groups are joined together
23.04.2023
hard1416. Restore The Array
use Long to avoid overflow
22.04.2023
hard1312. Minimum Insertion Steps to Make a String Palindrome
Just DFS and cache.
18.04.2023
easy1768. Merge Strings Alternately
we can use sequence zip operator
14.04.2023
medium516. Longest Palindromic Subsequence
For cleaner code
12.04.2023
medium71. Simplify Path
split the string by /
11.04.2023
medium2390. Removing Stars From a String
we can use a Stack, or just StringBuilder
10.04.2023
medium20. Valid Parentheses
use HashMap to check matching bracket.
09.04.2023
hard1857. Largest Color Value in a Directed Graph
use visited set to detect cycles
04.04.2023
medium2405. Optimal Partition of String
use hashset, [26] array or simple 32-bit mask to store visited flags for character
31.03.2023
hard1444. Number of Ways of Cutting a Pizza
carefully precompute prefix sum. You move by row, increasing sumX, then you move by column and reuse the result of the previous row.
19.03.2023
medium211. Design Add and Search Words Data Structure
Let's try to write it in a Kotlin way, using as little words as possible.
18.03.2023
medium1472. Design Browser History
Just implement it.
17.03.2023
medium208. Implement Trie (Prefix Tree)
Let's try to write it Kotlin-way
03.03.2023
medium28. Find the Index of the First Occurrence in a String
carefull with indexes
02.03.2023
medium443. String Compression
Let's just do a naive toString for simplicity.
28.02.2023
medium652. Find Duplicate Subtrees
Let's use pre-order traversal and serialize each node into string, also add that into HashSet and check for duplicates.
26.02.2023
hard72. Edit Distance
Do DFS and use array for memoizing the result.
14.02.2023
easy67. Add Binary
keep track of the overflow
9.02.2023
hard2306. Naming a Company
Group and multiply. Don't forget to remove repeating elements in each two groups.
5.02.2023
medium438. Find All Anagrams in a String
To avoid checking a frequencies arrays, we can count how many frequencies are not matching, and add only when non-matching count is zero.
4.02.2023
medium567. Permutation in String
to decrease cost of comparing arrays, we can also use hashing
3.02.2023
medium6. Zigzag Conversion
Store simulation result in a [rowsNum][simulation indice] - matrix, then build the result.
2.02.2023
easy953. Verifying an Alien Dictionary
Just translate and then sort and compare. (But we can also just scan linearly and compare).
1.02.2023
easy1071. Greatest Common Divisor of Strings
We can first find the length of the greatest common divisor, then just check both strings.
27.01.2023
hard472. Concatenated Words
first, scan all the words, and fill the Trie
22.01.2023
medium131. Palindrome Partitioning
fun partition(s: String): List> {
21.01.2023
medium93. Restore IP Addresses
fun restoreIpAddresses(s: String): List
17.01.2023
medium926. Flip String to Monotone Increasing
fun minFlipsMonoIncr(s: String): Int {
14.01.2023
medium1061. Lexicographically Smallest Equivalent String
fun smallestEquivalentString(s1: String, s2: String, baseStr: String): String {
13.01.2023
hard2246. Longest Path With Different Adjacent Characters
fun longestPath(parent: IntArray, s: String): Int {
12.01.2023
medium1519. Number of Nodes in the Sub-Tree With the Same Label
fun countSubTrees(n: Int, edges: Array
3.01.2023
easy944. Delete Columns to Make Sorted
fun minDeletionSize(strs: Array
2.01.2023
easy520. Detect Capital
fun detectCapitalUse(word: String): Boolean =
1.01.2023
easy290. Word Pattern
fun wordPattern(pattern: String, s: String): Boolean {
17.12.2022
medium150. Evaluate Reverse Polish Notation
fun evalRPN(tokens: Array
15.12.2022
medium1143. Longest Common Subsequence
fun longestCommonSubsequence(text1: String, text2: String): Int {
3.12.2022
medium451. Sort Characters By Frequency
fun frequencySort(s: String): String =
2.12.2022
mediumDetermine If Two Strings Are Close
// cabbba -> c aa bbb -> 1 2 3
1.12.2022
easy1704. Determine if String Halves Are Alike
fun halvesAreAlike(s: String): Boolean {
24.11.2022
medium79. Word Search
fun exist(board: Array
20.11.2022
hardBasic Calculator
fun calculate(s: String): Int {
13.11.2022
mediumReverse Words In A String
A simple trick: reverse all the string, then reverse each word.
10.11.2022
easyRemove All Adjacent Duplicates In String
Just scan symbols one by one and remove duplicates from the end.
8.11.2022
easyMake The String Great
The simplest solution is just to simulate all the process, as input string is just 100 symbols.
6.11.2022
hardOrderly Queue
One idea that come to my mind is: if k >= 2 then you basically can swap any adjacent elements. That means you can actually sort all the characters.
6.11.2022
hardWord Search Ii
Use trie + dfs
4.11.2022
easyReverse Vowels Of A String
Straightforward solution : use two pointers method and scan from the both sides.
3.11.2022
mediumLongest Palindrome By Concatenating Two Letter Words
This is a counting task, can be solved linearly.
2.11.2022
mediumMinimum Genetic Mutation
make graph