↓Skip to main content

LeetCode

LeetCode 1155: Number of Dice Rolls With Target Sum
·3 mins
LeetCode Medium Dynamic-Programming Counting
LeetCode note for Number of Dice Rolls With Target Sum, rebuilt from the original learning note
LeetCode 879: Profitable Schemes
·3 mins
LeetCode Hard Dynamic-Programming Knapsack
LeetCode note for Profitable Schemes, rebuilt from the original learning note
LeetCode 474: Ones and Zeroes
·3 mins
LeetCode Medium Dynamic-Programming Knapsack
LeetCode note for Ones and Zeroes, rebuilt from the original learning note
LeetCode 1449: Form Largest Integer With Digits That Add Up To Target
·3 mins
LeetCode Hard Dynamic-Programming Knapsack
LeetCode note for Form Largest Integer With Digits That Add Up To Target, rebuilt from the original learning note
LeetCode 1049: Last Stone Weight II
·3 mins
LeetCode Medium Dynamic-Programming Knapsack Subset-Sum
LeetCode note for Last Stone Weight II, rebuilt from the original learning note
LeetCode 327: Count of Range Sum
·3 mins
LeetCode Hard Merge-Sort Divide-and-Conquer Prefix-Sum Binary-Indexed-Tree
LeetCode 327 note: prefix sums plus merge sort counting with two pointers bounding a range, and a log of retyping it over a dozen times
LeetCode 2392: Build a Matrix With Conditions
·2 mins
LeetCode Hard Graph Topological-Sort Matrix
LeetCode 2392 note: row and column conditions are independent, so run one topological sort for each; put x at its row and column positions, and return an empty matrix if either has a cycle
LeetCode 2102: Sequentially Ordinal Rank Tracker
·3 mins
LeetCode Hard Heap Design Two-Heaps
LeetCode 2102 note: two heaps for “top k” and “the rest”, with a custom lt for reversed string order
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 2912: Number of Ways to Reach Destination in the Grid
·3 mins
LeetCode Hard Dynamic-Programming State-Machine Math Combinatorics
LeetCode 2912 note: many cells, but only four classes relative to the destination (itself, same row, same column, neither); each class’s total moves together in O(k)
LeetCode 60: Permutation Sequence
·2 mins
LeetCode Hard Math Combinatorics Recursion
LeetCode 60 note: make k 0-indexed; once the first digit is fixed there are (n-1)! arrangements, so k // (n-1)! picks the first digit among those remaining, then repeat for the next position
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