Array
LeetCode 4041: Minimum Operations to Form Subset Sum II
·2 mins
LeetCode
Hard
Dynamic-Programming
Knapsack
Breadth-First-Search
Array
LeetCode 4041 note: with operations in any order, BFS finds every value a number can become (up to sum) with the fewest steps, then the same grouped 0/1 knapsack as 4040
LeetCode 4040: Minimum Operations to Form Subset Sum I
·2 mins
LeetCode
Medium
Dynamic-Programming
Knapsack
Array
LeetCode 4040 note: with multiplications before divisions, the best is always multiply-only or divide-only; list each number’s reachable values and costs, then run a grouped 0/1 knapsack
LeetCode 2585: Number of Ways to Earn Points
·2 mins
LeetCode
Hard
Dynamic-Programming
Knapsack
Array
LeetCode 2585 note: a bounded (grouped) knapsack; each question type takes 0 to count questions, with capacity running backwards and the count enumerated inside
LeetCode 410: Split Array Largest Sum
·2 mins
LeetCode
Hard
Dynamic-Programming
Binary-Search
Greedy
Prefix-Sum
Array
LeetCode 410 note: binary search the answer; for a cap mid, greedily fill each segment to count the fewest segments, and mid works if that count is <= k
LeetCode 3895: Count Digit Appearances
·1 min
LeetCode
Medium
Math
Array
LeetCode 3895 note: convert each number to a string and add up how many times the digit appears
LeetCode 1235: Maximum Profit in Job Scheduling
·2 mins
LeetCode
Hard
Dynamic-Programming
Binary-Search
Sorting
Array
LeetCode 1235 note: sort jobs by end time with best[j] = best profit using the first j jobs; taking job j binary-searches the last job ending <= its start
LeetCode 3873: Maximum Points Activated with One Addition
·2 mins
LeetCode
Hard
Union-Find
Hash-Table
Array
LeetCode 3873 note: merge points sharing an x or y into components; a new point joins at most two of them, so the answer is the two largest plus 1
LeetCode 2382: Maximum Segment Sum After Removals
·2 mins
LeetCode
Hard
Union-Find
Prefix-Sum
Ordered-Set
Array
LeetCode 2382 note: work backward so removals become additions; the Union-Find root stores the segment sum, and the maximum only grows
LeetCode 2355: Maximum Number of Books You Can Take
·2 mins
LeetCode
Hard
Dynamic-Programming
Monotonic-Stack
Stack
Array
LeetCode 2355 note: ending at i, each shelf to the left takes one fewer book until a bottleneck shelf j with too few books; a monotonic stack finds j, and dp[i] = dp[j] + an arithmetic series
LeetCode 3989: Maximum Consistent Columns in a Grid
·2 mins
LeetCode
Hard
Dynamic-Programming
Matrix
Array
LeetCode 3989 note: the kept columns form a subsequence constrained only between neighbors; an LIS-style DP with dp[j] = the longest valid sequence ending at column j
LeetCode 1402: Reducing Dishes
·2 mins
LeetCode
Hard
Dynamic-Programming
Greedy
Sorting
Array
LeetCode 1402 note: sort and take dishes from most satisfying down; each new dish goes first and shifts the chosen ones one slot later, adding the current chosen sum, so keep going while that sum is positive
LeetCode 1526: Minimum Number of Increments on Subarrays to Form a Target Array
·1 min
LeetCode
Hard
Dynamic-Programming
Greedy
Monotonic-Stack
Array
LeetCode 1526 note: scanning left to right, every rise above the previous height needs that many new operations; drops reuse earlier operations