
dp
Belle唯唯
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[leetcode]62. Unique Paths
Solution 1:二维的dp 时间复杂度:0(mn) 空间复杂度:0(mn) class Solution { public int uniquePaths(int m, int n) { int [][] dp = new int[n][m]; for(int i = 0; i < m ;i++){ dp[0][i] = ...原创 2019-08-08 20:20:43 · 139 阅读 · 0 评论 -
[leetcode]63. Unique Paths II
Solution: dp 同62题。一行一行向下扫 class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { int m = obstacleGrid.length; int n = obstacleGrid[0].length; int[] dp...原创 2019-08-08 20:55:40 · 144 阅读 · 0 评论 -
[leetcode]279. Perfect Squares
自己写的 时间复杂度差 class Solution { public int numSquares(int n) { int [] dp = new int[n+1]; Arrays.fill(dp, Integer.MAX_VALUE); for(int i = 1 ;i <= n ;i++){ ...原创 2019-08-08 22:20:28 · 101 阅读 · 0 评论 -
[leetcode]97. Interleaving String
class Solution { public boolean isInterleave(String s1, String s2, String s3) { int m = s1.length() + 1; int n = s2.length() + 1; if(m + n - 2 != s3.length()) return false;...原创 2019-08-20 13:38:53 · 93 阅读 · 0 评论 -
[leetcode]188. Best Time to Buy and Sell Stock IV
public int maxProfit(int k, int[] prices) { int len = prices.length; if (k >= len / 2) return quickSolve(prices); int[][] t = new int[k + 1][len]; for (int ...原创 2019-08-12 12:09:14 · 125 阅读 · 0 评论 -
[leetcode]91. Decode Ways
Solution 1: O(n) dp dp初始化,为空的时候也有一种编码方式,所以dp【0】= 1; “0” 没有编码方式 class Solution { public int numDecodings(String s) { if(s == null || s.length() == 0) return 0; int len = s.length();...原创 2019-08-12 23:31:31 · 111 阅读 · 0 评论