Memoization
Interval DP
·4 mins
Algorithm
Dynamic-Programming
Interval-Dp
Memoization
Binary-Search
Interval DP (choose the last step / merge equal ends), partition DP into k segments, palindrome tables plus partitioning, and memoizing the whole state when it is too tangled to split
LeetCode 773: Sliding Puzzle
·2 mins
LeetCode
Hard
Breadth-First-Search
Dynamic-Programming
Memoization
Matrix
LeetCode 773 note: there are only 6! = 720 boards, so flatten each board into a string as a BFS state, with swaps of 0 and a neighbor as the moves
LeetCode 2328: Number of Increasing Paths in a Grid
·2 mins
LeetCode
Hard
Dynamic-Programming
Grid-Dp
Memoization
Topological-Sort
Matrix
LeetCode 2328 note: strictly increasing means no cycles; dp[cell] = 1 + Σ dp[larger neighbors], processed from largest to smallest value (or by memoized DFS), summed over all cells
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 397: Integer Replacement
·2 mins
LeetCode
Medium
Dynamic-Programming
Greedy
Bit-Manipulation
Memoization
LeetCode 397 note: even numbers are always halved; for odd numbers try +1 and -1 with memoized recursion, since n is too large for an n-sized array
LeetCode 1137: N-th Tribonacci Number
·2 mins
LeetCode
Easy
Math
Dynamic-Programming
Memoization
LeetCode 1137 note: like Fibonacci, roll three variables; watch the base values T0 = 0, T1 = T2 = 1 and the loop range
LeetCode 509: Fibonacci Number
·1 min
LeetCode
Easy
Math
Dynamic-Programming
Recursion
Memoization
LeetCode 509 note: the starting point of 1D DP; only the previous two terms are needed, so roll two variables