![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
dp
文章平均质量分 56
dawn_ricardo_y
这个作者很懒,什么都没留下…
展开
-
[LeetCode] DP之 Best time to buy and sell stock with transaction fee
题目分析这题是我很少做过的dp,和之前那个树的最小和问题有点像,因为它是有多个状态交错依赖的。这题中有四个行为: 没有股票的情况下:买股票 没有股票的情况下:什么也不做 有股票的情况下:卖股票 有股票的情况下:什么也不做 它特殊的地方就在于不止有买卖这两种操作,还有有没有股票的持有与否。所以比较明确的思路就需要四个数组。当然,这在之后可以进行优化。然后的思路就很简单了 你要买,就必须之前没有股票原创 2017-11-12 21:29:31 · 155 阅读 · 0 评论 -
[LeetCode] DP 之 Maximum Length of Repeated Substring
题目Given two integer arrays A and B, return the maximum length of an subarray that appears in both arrays.Example 1: Input: A: [1,2,3,2,1] B: [3,2,1,4,7] Output: 3 Explanation: The rep原创 2017-11-05 10:11:46 · 154 阅读 · 0 评论 -
[LeetCode] DP 之 Edit Distance
题目Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a)原创 2017-11-26 16:23:10 · 175 阅读 · 0 评论 -
[LeetCode] 最长公共子序列
题目 这个问题就是最长公共子序列问题,区别与我之前做过的最长公共子串问题。典型的这类问题的形式如下: 有两个串:x和y,长度分别为m和n,求它们的最长公共子序列。 分析 这题主要就是两个方面。首先,对于其最长公共子序列z,肯定有以下两种情况的其中一种: z_k = x_m = y_n,此时,z_k-1肯定在剩下的子串x.substring(0, m-1) 和 y.substring原创 2018-01-13 14:56:02 · 1872 阅读 · 1 评论