網格・雙序列 DP Grid / Two-Sequence DP
32 題(23 題以此為主技法)
🎯 何時用
二維表格上的路徑數/最小成本,或兩序列比較(LCS、編輯距離)。
🧩 模板心法
dp[i][j] 由上、左、左上轉移;邊界初始化要小心。可滾動成一維。
Medium 17 題
- #62Unique Paths
- #1143Longest Common Subsequence
- #63Unique Paths II
- #64Minimum Path Sum
- #72Edit Distance
- #97Interleaving String
- #221Maximal Square
- #309Best Time to Buy and Sell Stock with Cooldown
- #516Longest Palindromic Subsequence
- #877Stone Game
- #926Flip String to Monotone Increasing
- #1911Maximum Alternating Subsequence Sum
- #474Ones and Zeroes
- #494Target Sum
- #518Coin Change II
- #1049Last Stone Weight II
- #1140Stone Game II
Hard 15 題
- #10Regular Expression Matching
- #123Best Time to Buy and Sell Stock III
- #44Wildcard Matching
- #115Distinct Subsequences
- #174Dungeon Game
- #188Best Time to Buy and Sell Stock IV
- #329Longest Increasing Path in a Matrix
- #920Number of Music Playlists
- #1220Count Vowels Permutation
- #1639Number of Ways to Form a Target String Given a Dictionary
- #1866Number of Ways to Rearrange Sticks With K Sticks Visible
- #312Burst Balloons
- #879Profitable Schemes
- #1547Minimum Cost to Cut a Stick
- #2218Maximum Value of K Coins from Piles