Simulation
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 2105: Watering Plants II
·2 mins
LeetCode
Medium
Two-Pointers
Simulation
Array
LeetCode 2105 note: Alice from the left and Bob from the right, simulated with converging pointers; when they meet at the same plant, whoever has more water waters it
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 3679: Minimum Discards to Balance Inventory
·3 mins
LeetCode
Medium
Sliding-Window
Hash-Table
Simulation
Counting
Array
LeetCode 3679 note: the rule already decides what must be discarded, so simulate it; the length-w window counts only kept arrivals, and discarded ones must not be subtracted when they leave
LeetCode 3703: Remove K-Balanced Substrings
·2 mins
LeetCode
Medium
Stack
String
Simulation
LeetCode 3703 note: repeated replace is O(n^2); a stack of (character, run length) removes k ( plus k ) as soon as they line up
LeetCode 3701: Compute Alternating Sum
·1 min
LeetCode
Easy
Array
Simulation
LeetCode 3701 note: add even indices and subtract odd ones; with slices, sum(nums[::2]) - sum(nums[1::2])
LeetCode 3688: Bitwise OR of Even Numbers in an Array
·1 min
LeetCode
Easy
Bit-Manipulation
Array
Simulation
LeetCode 3688 note: OR only the even numbers; the starting value 0 is also the answer when there are none
LeetCode 853: Car Fleet
·2 mins
LeetCode
Daily
Medium
Array
Stack
Greedy
Simulation
Sorting
Solving the Car Fleet problem using stack-based approach
LeetCode 1222: Queens That Can Attack the King
·2 mins
LeetCode
Medium
Array
Matrix
Simulation
LeetCode 1222 note: step outward from the king in eight directions; the first queen met in each direction can attack, with queens in a set for lookups
LeetCode 2402: Meeting Rooms III
·3 mins
LeetCode
Hard
Heap
Sorting
Simulation
Intervals
LeetCode 2402 note: one heap for free rooms and one for busy rooms; a delayed meeting keeps its original length
LeetCode 3612: Process String with Special Operations I
·2 mins
LeetCode
Medium
String
Simulation
LeetCode 3612 note: simulate the four operations with a list; put the “result is non-empty” check inside the * branch, or * gets appended as a letter
LeetCode 1920: Build Array from Permutation
·1 min
LeetCode
Easy
Array
Simulation
LeetCode 1920 note: follow the definition ans[i] = nums[nums[i]]; for O(1) extra space, stack the new value times n on top of the old one