Array
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 1431: Kids With the Greatest Number of Candies
·1 min
LeetCode
Easy
Array
LeetCode 1431 note: compute the maximum once; a kid is True when their candies plus the extra reach >= the maximum, since a tie counts
LeetCode 3487: Maximum Unique Subarray Sum After Deletion
·2 mins
LeetCode
Easy
Greedy
Hash-Table
Array
LeetCode 3487 note: free deletion means picking distinct values; take every non-negative one, or only the maximum when all are negative
LeetCode 3131: Find the Integer Added to Array I
·1 min
LeetCode
Easy
Array
LeetCode 3131 note: every element gets the same x, so x is the difference of the two minimums (or of the sums divided by the length)
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 1814: Count Nice Pairs in an Array
·1 min
LeetCode
Medium
Array
Hash-Table
Math
Counting
LeetCode 1814 note: rearrange the condition into nums[i] - rev(nums[i]) == nums[j] - rev(nums[j]), count pairs per value, and remember the modulus
LeetCode 3075: Maximize Happiness of Selected Children
·1 min
LeetCode
Medium
Array
Greedy
Sorting
LeetCode 3075 note: choose k children from the happiest, where the i-th choice loses i, floored at 0
LeetCode 3074: Apple Redistribution into Boxes
·1 min
LeetCode
Easy
Array
Greedy
Sorting
LeetCode 3074 note: apples can be split freely, so take boxes from the largest capacity until the total fits every apple
LeetCode 3071: Minimum Operations to Write the Letter Y on a Grid
·2 mins
LeetCode
Medium
Array
Hash-Table
Matrix
Counting
LeetCode 3071 note: count each value on and off the Y, enumerate the Y value a and background value b (a != b), and take the fewest cells to change
LeetCode 3070: Count Submatrices with Top-Left Element and Sum Less Than k
·2 mins
LeetCode
Medium
Array
Matrix
Prefix-Sum
LeetCode 3070 note: submatrices containing the top-left corner are exactly the 2D prefix sums P[i][j]; count those <= k
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