String
LeetCode 3325: Count Substrings With K-Frequency Characters I
·2 mins
LeetCode
Medium
Sliding-Window
Hash-Table
String
LeetCode 3325 note: an “at least one character appears k times” counting window; when the new character reaches k, keep shrinking until it drops to k - 1
LeetCode 1358: Number of Substrings Containing All Three Characters
·2 mins
LeetCode
Medium
Sliding-Window
Hash-Table
String
LeetCode 1358 note: an “at least one each of a, b, c” counting window: keep shrinking while all three are present, then count += left
LeetCode 3816: Lexicographically Smallest String After Deleting Duplicate Characters
·3 mins
LeetCode
Hard
Stack
Monotonic-Stack
Greedy
String
LeetCode 3816 note: a monotonic stack that deletes a larger top while another copy exists, then trims duplicate letters off the end since a prefix is always smaller
LeetCode 3813: Vowel-Consonant Score
·1 min
LeetCode
Easy
String
Simulation
LeetCode 3813 note: count letters only, split into vowels and consonants; the score is 0 with no consonants, otherwise integer division
LeetCode 3258: Count Substrings That Satisfy K-Constraint I
·2 mins
LeetCode
Easy
Sliding-Window
String
LeetCode 3258 note: valid means zeros <= k or ones <= k; it is invalid only when both exceed k, and after shrinking there are right - left + 1 valid substrings ending at right
LeetCode 2904: Shortest and Lexicographically Smallest Beautiful String
·2 mins
LeetCode
Medium
Sliding-Window
String
LeetCode 2904 note: with exactly k ones in the window, also shrink away leading zeros to get the shortest beautiful substring ending at right; compare by length first, then lexicographically
LeetCode 1234: Replace the Substring for Balanced String
·2 mins
LeetCode
Medium
Sliding-Window
String
LeetCode 1234 note: after replacing a window, every character outside it must be at most n / 4; a shortest-window slide tracks the counts outside the window
LeetCode 395: Longest Substring with At Least K Repeating Characters
·3 mins
LeetCode
Medium
Sliding-Window
Divide-and-Conquer
Hash-Table
String
LeetCode 395 note: “every character at least k times” is not monotonic, so a direct slide fails; divide and conquer splits on characters with fewer than k occurrences, or fixing the number of distinct characters makes the window slidable
LeetCode 1763: Longest Nice Substring
·2 mins
LeetCode
Easy
Sliding-Window
Divide-and-Conquer
Hash-Table
String
Bit-Manipulation
LeetCode 1763 note: a character whose other case never appears cannot be in the answer, so split on it and recurse, preferring the left side on ties
LeetCode 2781: Length of the Longest Valid Substring
·3 mins
LeetCode
Hard
Sliding-Window
Hash-Table
String
Trie
LeetCode 2781 note: forbidden words are at most 10 long, so each right end checks only the last 10 suffixes; on a match push the left end past it, using the shortest match (the rightmost start)
LeetCode 3805: Count Caesar Cipher Pairs
·2 mins
LeetCode
Medium
Math
Hash-Table
String
Counting
LeetCode 3805 note: shift each string so its first letter is a, making Caesar-equivalent strings identical, then count pairs per normalized form
LeetCode 3803: Count Residue Prefixes
·1 min
LeetCode
Easy
Hash-Table
String
LeetCode 3803 note: add characters to a set while scanning; count a prefix when its distinct count equals its length % 3