摘要:
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iv/ class Solution { public int maxProfit(int k, int[] prices) { // 由于可以交易k次,以多少次持有来划分状态 阅读全文
摘要:
https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/ 经典股票题,此题有贪心做法 class Solution { public int maxProfit(int[] prices) { int res = 0; int min 阅读全文
摘要:
https://leetcode.cn/problems/coin-change/description/ 代码上比较麻烦的dp题,由于求的是最少数量,因此求答案时需要初始化无穷大来计算 class Solution { public int coinChange(int[] coins, int 阅读全文
摘要:
https://leetcode.cn/problems/combination-sum-iv/description/ 此篇题解解释了为什么不能直接用二维完全背包的方式做不过还是建议把这个题当成一个爬楼梯来做 class Solution { public: int combinationSum4 阅读全文