↓Skip to main content

String

LeetCode 777: Swap Adjacent in LR String
·2 mins
LeetCode Medium Two-Pointers String
LeetCode 777 note: XL→LX moves L left and RX→XR moves R right; after skipping X the order must match, with L only moving left and R only moving right
LeetCode 2337: Move Pieces to Obtain a String
·2 mins
LeetCode Medium Two-Pointers String
LeetCode 2337 note: after skipping blanks the piece order must match; L only moves left and R only moves right, so each L’s start index must be >= its target index and each R’s must be <=
LeetCode 809: Expressive Words
·3 mins
LeetCode Medium Two-Pointers String Array
LeetCode 809 note: two pointers compare runs of equal characters; when the lengths differ, the run in s must be at least 3 and no shorter than the word’s run, and both strings must end together
LeetCode 3823: Reverse Letters Then Special Characters in a String
·2 mins
LeetCode Easy Two-Pointers String
LeetCode 3823 note: two converging-pointer passes, swapping only letters the first time and only special characters the second
LeetCode 2273: Find Resultant Array After Removing Anagrams
·2 mins
LeetCode Easy Hash-Table String Sorting
LeetCode 2273 note: repeatedly deleting a word that is an anagram of the previous one keeps exactly the words that are not anagrams of the last kept word; compare sorted strings
LeetCode 3775: Reverse Words With Same Vowel Count
·1 min
LeetCode Medium String Simulation Two-Pointers
LeetCode 3775 note: count the first word’s vowels, then reverse every later word with the same count
LeetCode 2697: Lexicographically Smallest Palindrome
·2 mins
LeetCode Easy Two-Pointers String Greedy
LeetCode 2697 note: converging pointers, setting both ends to the smaller character whenever they differ
LeetCode 1750: Minimum Length of String After Deleting Similar Ends
·3 mins
LeetCode Medium Two-Pointers String
LeetCode 1750 note: when both ends match, each side eats its whole run of that character; a string of one repeated character can be deleted entirely
LeetCode 1616: Split Two Strings to Make Palindrome
·3 mins
LeetCode Medium Two-Pointers String Greedy
LeetCode 1616 note: greedily match a’s prefix against b’s suffix from the outside in; the leftover middle must be a palindrome entirely within a or b, and both directions need checking
LeetCode 1156: Swap For Longest Repeated Character Substring
·2 mins
LeetCode Medium Sliding-Window Hash-Table String
LeetCode 1156 note: for each character c, find the longest window with at most one non-c; the swapped-in c must come from elsewhere, so the length is capped at the total count of c
LeetCode 3306: Count of Substrings Containing Every Vowel and K Consonants II
·2 mins
LeetCode Medium Sliding-Window Hash-Table String
LeetCode 3306 note: “exactly k consonants” is not monotonic; compute “all five vowels and at least k consonants” minus “at least k + 1”, both “at least” counting windows
LeetCode 3298: Count Substrings That Can Be Rearranged to Contain a String II
·2 mins
LeetCode Hard Sliding-Window Hash-Table String
LeetCode 3298 note: rearrangeable to start with word2 ⇔ every character count is at least word2’s; an “at least” counting window where meet tracks how many characters have reached their target