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’ -> 26 Given a non-empty string containing only digits, determin...原创 2019-04-10 04:58:28 · 155 阅读 · 0 评论 -
Leetcode 309. Best Time to Buy and Sell Stock with Cooldown
Problem: Analysis: DP is like induction prove. define the base case define the inductive rule Code: public int maxProfit(int[] prices) { if (prices == null || prices.length <= ...原创 2019-06-13 04:07:23 · 157 阅读 · 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 · 145 阅读 · 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 · 198 阅读 · 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 · 181 阅读 · 0 评论
分享