↓Skip to main content

Easy

LeetCode 1108: Defanging an IP Address
·1 min
LeetCode Easy String
LeetCode 1108 note: replace every . with [.]
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 1089: Duplicate Zeros
·2 mins
LeetCode Easy Array Two-Pointers
LeetCode 1089 note: count the zeros to know each value’s shift, then move from back to front, writing the extra 0 when copying a zero
LeetCode 1078: Occurrences After Bigram
·1 min
LeetCode Easy String
LeetCode 1078 note: split into words and check every three consecutive words, collecting the third when the first two match
LeetCode 1051: Height Checker
·1 min
LeetCode Easy Array Sorting Counting-Sort Bubble-Sort
LeetCode 1051 note: sort and count the positions that differ from the original
LeetCode 1047: Remove All Adjacent Duplicates In String
·1 min
LeetCode Easy String Stack
LeetCode 1047 note: if the stack top equals the current character both vanish, otherwise push it; after a removal the new top may cancel with the next character
LeetCode 1046: Last Stone Weight
·2 mins
LeetCode Easy Array Heap-Priority-Queue
LeetCode 1046 note: from a max-heap (negated values) take the two heaviest each round, push back their difference if unequal, and return the last stone or 0
LeetCode 1030: Matrix Cells in Distance Order
·2 mins
LeetCode Easy Array Math Geometry Sorting
LeetCode 1030 note: list every coordinate and sort by Manhattan distance to the center; return coordinates, not distances
LeetCode 997: Find the Town Judge
·2 mins
LeetCode Easy Array Hash-Table Graph
LeetCode 997 note: the judge is trusted by the other n - 1 people and trusts nobody, so in-degree minus out-degree equals n - 1
LeetCode 1025: Divisor Game
·2 mins
LeetCode Easy Math Dynamic-Programming Brainteaser Game-Theory
LeetCode 1025 note: dp[i] holds when some divisor x of i makes dp[i - x] a loss; observing the pattern, the answer is simply whether n is even
LeetCode 1022: Sum of Root To Leaf Binary Numbers
·2 mins
LeetCode Easy Tree Depth-First-Search Binary-Tree
LeetCode 1022 note: on the way down double the current number and add the node’s bit, adding it to the total at a leaf
LeetCode 1021: Remove Outermost Parentheses
·1 min
LeetCode Easy String Stack Bracket-Sequences
LeetCode 1021 note: track depth instead of a stack; the ‘(’ raising depth from 0 to 1 and the ‘)’ lowering it from 1 to 0 are outermost, everything else stays