Hard
LeetCode 2141: Maximum Running Time of N Computers
·3 mins
LeetCode
Hard
Greedy
Binary-Search
Sorting
LeetCode 2141 note: a battery longer than the average can only serve one computer, so remove it with that computer and average the rest, using strict greater-than
LeetCode 902: Numbers At Most N Given Digit Set
·2 mins
LeetCode
Hard
Dynamic-Programming
Digit-Dp
Math
Binary-Search
String
LeetCode 902 note: digit DP with state (pos, tight, started); before starting, a position can be skipped, representing numbers with fewer digits than n
LeetCode 3548: Equal Sum Grid Partition II
·3 mins
LeetCode
Hard
Prefix-Sum
Hash-Table
Matrix
Enumeration
LeetCode 3548 note: try each horizontal cut (transpose for vertical); the difference must equal a cell on the larger side, and a one-row or one-column side can only drop an end cell, while any cell works otherwise
LeetCode 980: Unique Paths III
·2 mins
LeetCode
Hard
Backtracking
Matrix
Dfs
LeetCode 980 note: grid backtracking that marks visited cells in place and checks at the end that every empty cell was covered
LeetCode 2421: Number of Good Paths
·3 mins
LeetCode
Hard
Tree
Union-Find
Graph
Sorting
LeetCode 2421 note: add nodes in increasing value order and count same-value nodes per Union-Find group
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 1092: Shortest Common Supersequence
·5 mins
LeetCode
Hard
Dynamic-Programming
String
LeetCode note for Shortest Common Supersequence, rebuilt from the original learning note
LeetCode 1312: Minimum Insertion Steps to Make a String Palindrome
·4 mins
LeetCode
Hard
Dynamic-Programming
String
Palindrome
LeetCode note for Minimum Insertion Steps to Make a String Palindrome, rebuilt from the original learning note
LeetCode 115: Distinct Subsequences
·3 mins
LeetCode
Hard
Dynamic-Programming
String
LeetCode note for Distinct Subsequences, rebuilt from the original learning note
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 726: Number of Atoms
·3 mins
LeetCode
Hard
Stack
String
Hash-Map
Sorting
LeetCode 726 note: tokenize into elements, numbers, and parentheses; handle parentheses with a stack, with a default multiplier of 1