LeetCode
LeetCode 925: Long Pressed Name
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 925 note: one pointer each over name and typed; every typed character either matches the next name character or repeats the previous typed character
LeetCode 922: Sort Array By Parity II
·1 min
LeetCode
Easy
Array
Two-Pointers
Sorting
LeetCode 922 note: pointers i over even slots and j over odd slots, each stepping by two; when slot i holds an odd number, move j to a misplaced even and swap
LeetCode 917: Reverse Only Letters
·2 mins
LeetCode
Easy
Two-Pointers
String
LeetCode 917 note: two pointers each skip non-letters and swap when both point at letters; convert the string to a list first
LeetCode 914: X of a Kind in a Deck of Cards
·2 mins
LeetCode
Easy
Array
Hash-Table
Math
Counting
LeetCode 914 note: every card count must be divisible by one X >= 2, i.e. the GCD of all counts is at least 2
LeetCode 908: Smallest Range I
·1 min
LeetCode
Easy
Array
Math
LeetCode 908 note: lower the maximum by k and raise the minimum by k; the answer is max(0, max - min - 2k)
LeetCode 905: Sort Array By Parity
·1 min
LeetCode
Easy
Array
Two-Pointers
Sorting
LeetCode 905 note: a write pointer swaps even numbers to the front, just like move zeroes
LeetCode 897: Increasing Order Search Tree
·1 min
LeetCode
Easy
Stack
Tree
Depth-First-Search
Binary-Search-Tree
LeetCode 897 note: in-order traversal appending nodes to a right-only chain with left children cleared; keep the dummy separate from the moving tail
LeetCode 896: Monotonic Array
·1 min
LeetCode
Easy
Array
LeetCode 896 note: monotonic means non-increasing or non-decreasing; check both directions, allowing equal neighbors
LeetCode 892: Surface Area of 3D Shapes
·2 mins
LeetCode
Easy
Array
Math
Geometry
Matrix
LeetCode 892 note: a stack of v cubes has 4v + 2 faces; subtract 2 × min for each overlap with the stacks above and to the left
LeetCode 888: Fair Candy Swap
·2 mins
LeetCode
Easy
Array
Hash-Table
Binary-Search
Sorting
LeetCode 888 note: equal sums after swapping x and y means y = x + (sumB - sumA) / 2; put B in a set and check each x from A
LeetCode 884: Uncommon Words from Two Sentences
·1 min
LeetCode
Easy
Hash-Table
String
Counting
LeetCode 884 note: count words across both sentences together; those appearing exactly once are the answer
LeetCode 883: Projection Area of 3D Shapes
·1 min
LeetCode
Easy
Array
Math
Geometry
Matrix
LeetCode 883 note: the top view counts nonzero cells, and the front and side views sum each row’s and each column’s maximum