![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
DP
Opium_Z
这个作者很懒,什么都没留下…
展开
-
Leetcode 91 Decode Ways
Problem:A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1‘B’ -> 2…‘Z’ -> 26Given a non-empty string containing only digits, determin...原创 2019-04-10 04:58:28 · 117 阅读 · 0 评论 -
Leetcode 309. Best Time to Buy and Sell Stock with Cooldown
Problem:Analysis:DP is like induction prove.define the base casedefine the inductive ruleCode:public int maxProfit(int[] prices) { if (prices == null || prices.length <= ...原创 2019-06-13 04:07:23 · 109 阅读 · 0 评论 -
Leetcode 516 Longest Palindromic Subsequence
Problem:Analysis:DP 问题的核心就是转化为数学归纳法;如果可以画出图就更好了time O(n^2)space O(n^2)Code:public int longestPalindromeSubseq(String s) { if (s == null || s.length() == 0) return 0; if(s.len...原创 2019-06-15 04:57:28 · 93 阅读 · 0 评论 -
Leetcode 322. Coin Change
Problem:Analysis:Obviously, this is a DP problem. we can try to figure out it from two aspects. Top to bottom or bottom to Top.The next step, we should reduce the time complexity and space complex...原创 2019-06-22 04:53:25 · 128 阅读 · 0 评论 -
Leetcode 518. Coin Change 2
Problem:Analysis:The analysis is the same as the Coin Change 1 (see previous post)Code:public int change1(int amount, int[] coins) { int[][] f = new int[coins.length + 1][amount + 1];...原创 2019-06-23 08:32:20 · 114 阅读 · 0 评论