Simulation
LeetCode 3507: Minimum Pair Removal to Sort Array I
·2 mins
LeetCode
Easy
Simulation
Array
LeetCode 3507 note: n is tiny, so simulate; the right side of a slice assignment must be a list
LeetCode 3494: Find the Minimum Amount of Time to Brew Potions
·2 mins
LeetCode
Medium
Simulation
Prefix-Sum
Array
LeetCode 3494 note: for each potion, push forward to get the last wizard’s finish time (everyone must be free), then subtract backward to get each wizard’s finish time
LeetCode 735: Asteroid Collision
·2 mins
LeetCode
Medium
Array
Stack
Simulation
LeetCode 735 note: scan left to right with a stack; only a right-moving top meeting a left-moving asteroid collides, the smaller explodes and equal sizes both do
LeetCode 3069: Distribute Elements Into Two Arrays I
·1 min
LeetCode
Easy
Array
Two-Pointers
Simulation
LeetCode 3069 note: simulate the rule: the first two go to separate arrays, then each element joins the array whose last element is larger
LeetCode 1646: Get Maximum in Generated Array
·2 mins
LeetCode
Easy
Array
Simulation
LeetCode 1646 note: generate by the rules, nums[i // 2] at even i and nums[i // 2] + nums[i // 2 + 1] at odd i, handling n = 0 separately
LeetCode 59: Spiral Matrix II
·2 mins
LeetCode
Medium
Array
Matrix
Simulation
LeetCode 59 note: keep four boundaries as in LC 54, but fill in 1 to n² instead of reading
LeetCode 54: Spiral Matrix
·2 mins
LeetCode
Medium
Array
Matrix
Simulation
LeetCode 54 note: keep four boundaries and walk right, down, left and up, shrinking a boundary after each side
LeetCode 43: Multiply Strings
·2 mins
LeetCode
Medium
Math
String
Simulation
LeetCode 43 note: num1[i] × num2[j] lands at position i + j + 1; accumulate into an array of length n + m and carry at the end
LeetCode 1103: Distribute Candies to People
·1 min
LeetCode
Easy
Math
Simulation
LeetCode 1103 note: simulate the rounds, giving i + 1 candies on the i-th turn, and hand all the rest to the current person when short
LeetCode 867: Transpose Matrix
·1 min
LeetCode
Easy
Array
Matrix
Simulation
LeetCode 867 note: the transpose is n × m with res[j][i] = matrix[i][j]; in Python, zip(*matrix)
LeetCode 844: Backspace String Compare
·2 mins
LeetCode
Easy
Two-Pointers
String
Stack
Simulation
LeetCode 844 note: simulate backspaces with a stack; for O(1) space, walk from the end and count how many characters each # skips
LeetCode 682: Baseball Game
·1 min
LeetCode
Easy
Array
Stack
Simulation
LeetCode 682 note: keep valid scores on a stack; C removes the last, D adds its double, and + adds the sum of the last two