↓Skip to main content

Easy

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
LeetCode 876: Middle of the Linked List
·2 mins
LeetCode Easy Linked-List Two-Pointers
LeetCode 876 note: fast moves two steps and slow one; when fast reaches the end slow is in the middle, the right-middle for even lengths
LeetCode 872: Leaf-Similar Trees
·1 min
LeetCode Easy Tree Depth-First-Search Binary-Tree
LeetCode 872 note: collect leaves left to right with DFS; BFS collects level by level, which is not left-to-right order
LeetCode 868: Binary Gap
·2 mins
LeetCode Easy Bit-Manipulation
LeetCode 868 note: remember the last 1’s position and take the maximum distance at each new 1
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 859: Buddy Strings
·2 mins
LeetCode Easy Hash-Table String
LeetCode 859 note: lengths must match; identical strings need a repeated character; otherwise exactly two positions differ and cross-match
LeetCode 844: Backspace String Compare
·2 mins
LeetCode Easy Two-Pointers String Stack Simulation
LeetCode 844 note: simulate backspaces with a stack; for O(1) space, walk from the end and count how many characters each # skips
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 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