↓Skip to main content

LeetCode

LeetCode 97: Interleaving String
·4 mins
LeetCode Medium Dynamic-Programming String
LeetCode note for Interleaving String, rebuilt from the original learning note
LeetCode 72: Edit Distance
·4 mins
LeetCode Medium Dynamic-Programming String
LeetCode note for Edit Distance, 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 316: Remove Duplicate Letters
·2 mins
LeetCode Medium Stack Monotonic-Stack Greedy String
LeetCode 316 note: a monotonic stack with last positions; pop a larger top that appears again later, and skip letters already on the stack
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
LeetCode 516: Longest Palindromic Subsequence
·3 mins
LeetCode Medium Dynamic-Programming String Palindrome
LeetCode note for Longest Palindromic Subsequence, rebuilt from the original learning note
LeetCode 1143: Longest Common Subsequence
·3 mins
LeetCode Medium Dynamic-Programming String
LeetCode note for Longest Common Subsequence, rebuilt from the original learning note
LeetCode 757: Set Intersection Size At Least Two
·2 mins
LeetCode Hard Greedy Sorting
LeetCode 757 note: sort by right end (larger left end first on ties) and track only the two rightmost points; add the two right-end points when uncovered, or the right end when only one is covered
LeetCode 552: Student Attendance Record II
·2 mins
LeetCode Hard Dynamic-Programming State-Machine
LeetCode 552 note: state machine DP with state “A used × trailing L run”, 6 states; each day’s P, A or L picks the next state
LeetCode 51: N-Queens
·2 mins
LeetCode Hard Backtracking
LeetCode 51 note: one queen per row, with three sets tracking occupied columns and both diagonals
LeetCode 488: Zuma Game
·3 mins
LeetCode Hard Dynamic-Programming Memoization Breadth-First-Search String Stack
LeetCode 488 note: with at most 16 balls on the board and 5 in hand, memoize DFS on the whole (board, hand) state, inserting only before a same-colored ball or between two equal balls
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