Medium
LeetCode 120: Triangle
·3 mins
LeetCode
Medium
Dynamic-Programming
LeetCode note for Triangle, rebuilt from the original learning note
LeetCode 2196: Create Binary Tree From Descriptions
·2 mins
LeetCode
Medium
Tree
Binary-Tree
Hash-Map
LeetCode 2196 note: keep nodes in a dict and link them in one pass; the root is the only value that is nobody’s child
LeetCode 3660: Jump Game IX
·2 mins
LeetCode
Medium
Dynamic-Programming
Array
LeetCode 3660 note: cutting between i and i+1, if the left max exceeds the right min the two sides reach each other and share the answer; otherwise the left answer is the left max
LeetCode 1878: Get Biggest Three Rhombus Sums in a Grid
·3 mins
LeetCode
Medium
Matrix
Enumeration
Heap
LeetCode 1878 note: enumerate every top vertex and size, walk the four edges, and keep the three largest distinct sums
LeetCode 1727: Largest Submatrix With Rearrangements
·2 mins
LeetCode
Medium
Greedy
Sorting
Matrix
LeetCode 1727 note: compute each row’s heights of consecutive ones above; columns can be reordered, so sort heights descending and the j-th tallest times j + 1 is a candidate
LeetCode 3713: Longest Balanced Substring I
·2 mins
LeetCode
Medium
Hash-Table
String
Counting
Enumeration
LeetCode 3713 note: fix the start and extend right; “every character has the same count” means “highest count × kinds = length”, an O(1) check per step
LeetCode 1833: Maximum Ice Cream Bars
·2 mins
LeetCode
Medium
Greedy
Sorting
Counting-Sort
LeetCode 1833 note: buy the cheapest first; the problem asks for counting sort, and with values up to 10^5 each price buys min(count, coins // price)
LeetCode 307: Range Sum Query - Mutable
·3 mins
LeetCode
Medium
Segment-Tree
Binary-Indexed-Tree
Design
Array
LeetCode 307 note: point updates with range sums make prefix sums O(n) per update; a segment tree or Fenwick tree makes both operations O(log n)
LeetCode 3961: Maximize Sum of Device Ratings
·2 mins
LeetCode
Medium
Greedy
Sorting
Matrix
LeetCode 3961 note: every device but one donates its smallest unit to the same device; that device’s rating becomes the global minimum, so pick the one with the smallest second-smallest value
LeetCode 3960: Frequency Balance Subarray
·2 mins
LeetCode
Medium
Hash-Table
Counting
Array
LeetCode 3960 note: n is only 1000, so fix the left end and extend right while maintaining value -> count and count -> how many; exactly two counts f and 2f means balanced
LeetCode 3952: Maximum Total Value of Covered Indices
·2 mins
LeetCode
Medium
Dynamic-Programming
State-Machine
Greedy
String
LeetCode 3952 note: each token moves left at most once, so the state is whether this index’s token moved left; moving only helps if the index to the left was not already covered
LeetCode 3951: Minimum Energy to Maintain Brightness
·2 mins
LeetCode
Medium
Array
Sorting
LeetCode 3951 note: a bulb lights at most 3 positions, so each time unit needs ceil(brightness / 3) bulbs; merge the intervals for the total time and multiply