摘要: https://leetcode.cn/problems/longest-common-subsequence/description/经典题,老题回顾 class Solution { public int longestCommonSubsequence(String text1, String 阅读全文
posted @ 2024-09-07 15:29 风乐 阅读(29) 评论(0) 推荐(0)
摘要: 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)