Math
LeetCode 989: Add to Array-Form of Integer
·2 mins
LeetCode
Easy
Array
Math
LeetCode 989 note: treat k as the carry, add from the last element backwards, and keep prepending digits while k remains
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 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 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
LeetCode 836: Rectangle Overlap
·2 mins
LeetCode
Easy
Math
Geometry
LeetCode 836 note: two rectangles overlap exactly when their x intervals and y intervals both overlap, i.e. min(right) > max(left)
LeetCode 812: Largest Triangle Area
·2 mins
LeetCode
Easy
Array
Math
Geometry
Polygons
LeetCode 812 note: with at most 50 points, enumerate every triple and take the largest shoelace area
LeetCode 762: Prime Number of Set Bits in Binary Representation
·1 min
LeetCode
Easy
Math
Bit-Manipulation
Primality-Test
LeetCode 762 note: numbers are below 10^6 < 2^20, so the set-bit count is at most 19; check it against a small set of primes
LeetCode 728: Self Dividing Numbers
·2 mins
LeetCode
Easy
Math
LeetCode 728 note: check every number in the range; each digit must be nonzero and divide the number
LeetCode 628: Maximum Product of Three Numbers
·1 min
LeetCode
Easy
Array
Math
Sorting
LeetCode 628 note: after sorting there are only two candidates: the three largest, or the two smallest (negatives) times the largest
LeetCode 598: Range Addition II
·2 mins
LeetCode
Easy
Array
Math
LeetCode 598 note: every operation covers the top-left corner, so the most-incremented cells form the intersection of all operations: min(a) × min(b)
LeetCode 509: Fibonacci Number
·1 min
LeetCode
Easy
Math
Dynamic-Programming
Recursion
Memoization
LeetCode 509 note: the starting point of 1D DP; only the previous two terms are needed, so roll two variables