上一页 1 2 3 4 5 6 7 8 9 ··· 21 下一页
摘要: https://leetcode.cn/problems/maximum-length-of-repeated-subarray/ 难点是在于状态定义,需要考虑到以第i个数为结尾,以第j个数为结尾的最长重复子数组 这样的定义而递推就很简单,只需要发生重复时+1即可,和之前的一维的,即最长子数组一样 阅读全文
posted @ 2024-09-07 15:28 风乐 阅读(32) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/longest-continuous-increasing-subsequence/description/ class Solution { public int findLengthOfLCIS(int[] nums) { // f[i] 阅读全文
posted @ 2024-09-07 14:23 风乐 阅读(19) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/longest-increasing-subsequence/description/ class Solution { public int lengthOfLIS(int[] nums) { // f[i]表示以第i个数为结尾的最长严格上 阅读全文
posted @ 2024-09-07 14:04 风乐 阅读(12) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/ class Solution { public int maxProfit(int[] prices, int fee) { // f 阅读全文
posted @ 2024-09-07 13:52 风乐 阅读(18) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-with-cooldown/description/ class Solution { public int maxProfit(int[] prices) { // f[i][ 阅读全文
posted @ 2024-09-07 03:59 风乐 阅读(29) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iv/ class Solution { public int maxProfit(int k, int[] prices) { // 由于可以交易k次,以多少次持有来划分状态 阅读全文
posted @ 2024-09-07 02:44 风乐 阅读(16) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-iii/description/ 这一题较难,难点是状态比较多,需要考虑两笔交易,则共5个状态需要被记录,用当前是否持有股票来划分子集进行计算 class Solution { 阅读全文
posted @ 2024-09-06 01:53 风乐 阅读(19) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock-ii/description/ class Solution { public: int maxProfit(vector<int>& prices) { vector<int> 阅读全文
posted @ 2024-09-06 00:39 风乐 阅读(13) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/best-time-to-buy-and-sell-stock/ 经典股票题,此题有贪心做法 class Solution { public int maxProfit(int[] prices) { int res = 0; int min 阅读全文
posted @ 2024-09-06 00:13 风乐 阅读(32) 评论(0) 推荐(0)
摘要: https://leetcode.cn/problems/house-robber-iii/description/基础树形dp,要点是f的定义灵神讲的很好:https://www.bilibili.com/video/BV1vu4y1f7dn/?vd_source=1bb76d0400eba0d4 阅读全文
posted @ 2024-09-05 02:06 风乐 阅读(14) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 21 下一页