647. 回文子串[https://leetcode.cn/problems/palindromic-substrings/] 算法思想 dp[i][j]表示[i,j]范圍內(nèi)...
647. 回文子串[https://leetcode.cn/problems/palindromic-substrings/] 算法思想 dp[i][j]表示[i,j]范圍內(nèi)...
121. 買賣股票的最佳時機[https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/] 動態(tài)規(guī)劃的思想。 ...
198. 打家劫舍[https://leetcode.cn/problems/house-robber/] 算法思想: 采用動態(tài)規(guī)劃的思想。當前的最大金額是由前兩個狀態(tài)決定的...
139. 單詞拆分[https://leetcode.cn/problems/word-break/] 算法思想: 完全背包中的排列問題。 dp[j] 表示長度位j的字符串是...
322. 零錢兌換[https://leetcode.cn/problems/coin-change/] 算法思想: 完全背包問題,求最少個數(shù),遞推公式為: dp[j] = ...
完全背包的理論基礎: 因為一個物品可以取多次,因此遍歷順序和0-1背包不同。 0-1背包遍歷背包的時候是倒序,這里是順序,允許重復,且物品和背包可以交換遍歷順序。 完全背包先...
1049. 最后一塊石頭的重量 II[https://leetcode.cn/problems/last-stone-weight-ii/] 算法思想: 可以轉(zhuǎn)化為0-1背包...
0-1背包問題: 有n個物品,價值為v,重量為w,裝進容量為c的背包中,問怎么裝使得背包價值最大。 算法思想:動態(tài)規(guī)劃 dp[i][j] 表示從0-i個物品中選擇加入容量為j...
343. 整數(shù)拆分 https://leetcode.cn/problems/integer-break/ 算法思想: dp[i] 對i進行拆分,獲得最大的乘積 遞推公式: ...
62. 不同路徑[https://leetcode.cn/problems/unique-paths/] https://leetcode.cn/problems/uniqu...
動態(tài)規(guī)劃做題思路。 關鍵點: 1.dp[i][j]理解dp數(shù)據(jù)和i和j的含義 2.遞歸公式 3.dp初始化 4.遍歷順序 5.打印dp數(shù)組 509. 斐波那契數(shù)[https:...
738. 單調(diào)遞增的數(shù)字[https://leetcode.cn/problems/monotone-increasing-digits/] https://leetcode...
491. 遞增子序列 題目鏈接:https://leetcode.cn/problems/non-decreasing-subsequences/ 算法思想: 回溯。 重要的...
435. 無重疊區(qū)間[https://leetcode.cn/problems/non-overlapping-intervals/] https://leetcode.cn...
860. 檸檬水找零 https://leetcode.cn/problems/lemonade-change/ 分情況討論: 用five 、ten 、twenty 3個變量...
1005. K 次取反后最大化的數(shù)組和 代碼鏈接:https://leetcode.cn/problems/maximize-sum-of-array-after-k-neg...
122. 買賣股票的最佳時機 II 題目鏈接:https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/...
455. 分發(fā)餅干 題目鏈接:https://leetcode.cn/problems/assign-cookies/ 算法思想:采用貪心算法實現(xiàn)。 將兩個數(shù)組進行排序,為每...
93. 復原 IP 地址 題目鏈接:https://leetcode.cn/problems/restore-ip-addresses/ 算法思想:回溯算法。 重要的是如何切...
39. 組合總和 代碼鏈接:https://leetcode.cn/problems/combination-sum/ 算法思想: 采用回溯的思想,由于數(shù)字可以重復使用,...