Array
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 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 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 860: Lemonade Change
·2 mins
LeetCode
Easy
Array
Greedy
LeetCode 860 note: track only the counts of $5 and $10 bills; for $15 change prefer 10 + 5, since $5 bills are more versatile
LeetCode 832: Flipping an Image
·2 mins
LeetCode
Easy
Array
Two-Pointers
Bit-Manipulation
Matrix
LeetCode 832 note: reverse each row and invert its bits, which two pointers can do at once
LeetCode 821: Shortest Distance to a Character
·2 mins
LeetCode
Easy
Array
Two-Pointers
String
LeetCode 821 note: one left-to-right pass for the distance to the nearest c on the left, then a right-to-left pass taking the minimum
LeetCode 819: Most Common Word
·2 mins
LeetCode
Easy
Array
Hash-Table
String
Counting
LeetCode 819 note: replace punctuation with spaces, lowercase, split, count, and pick the most frequent word not banned
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 806: Number of Lines To Write String
·2 mins
LeetCode
Easy
Array
String
LeetCode 806 note: simulate writing, wrapping when the next letter would exceed 100; landing exactly on 100 stays on the line
LeetCode 804: Unique Morse Code Words
·1 min
LeetCode
Easy
Array
Hash-Table
String
LeetCode 804 note: translate each word into a Morse string and count the distinct results with a set
LeetCode 766: Toeplitz Matrix
·2 mins
LeetCode
Easy
Array
Matrix
LeetCode 766 note: every diagonal is constant exactly when each cell equals its upper-left neighbor
LeetCode 748: Shortest Completing Word
·2 mins
LeetCode
Easy
Array
Hash-Table
String
LeetCode 748 note: count the plate’s letters in lowercase, then find the shortest word covering every count, taking the earliest on ties