LeetCode Unique Paths
来源:互联网 发布:西门子冰箱 知乎 编辑:程序博客网 时间:2024/05/17 00:07
public int uniquePaths(int m, int n) {if(m==1||n==1)return 1; int[][] matrix = new int[m][n]; matrix[m-1][n-1] = 1; for(int i=m-1;i>0;i--){ for(int j=n-1;j>0;j--){ if(j==n-1){ matrix[i-1][j] = matrix[i][j]; }else{ matrix[i-1][j] = matrix[i][j]+matrix[i-1][j+1]; } if(i==m-1){ matrix[i][j-1] = matrix[i][j]; }else{ matrix[i][j-1] = matrix[i][j]+matrix[i+1][j-1]; } } } matrix[0][0] = matrix[0][1]+matrix[1][0]; return matrix[0][0]; }
https://leetcode.com/problems/unique-paths/
做这种图形题一定要动手画图,考虑边界条件,只有图形才是最直观的,不能空想。
0 0
- leetcode Unique Paths && Unique Paths
- Leetcode-Unique Paths&Unique PathsII
- [LeetCode] Unique Paths and Unique Paths II
- leetcode--Unique Paths && Unique Paths ii
- leetcode--Unique Paths && Unique Paths ii
- 【Leetcode】【python】Unique Paths/Unique Paths II
- LeetCode: Unique Paths
- LeetCode: Unique Paths II
- [Leetcode] Unique Paths
- [Leetcode] Unique Paths II
- LeetCode : Unique Paths
- LeetCode : Unique Paths II
- leetcode 9: Unique Paths
- [LeetCode] Unique Paths
- [LeetCode] Unique Paths II
- [LeetCode]Unique Paths
- [LeetCode]Unique Paths II
- [LeetCode] Unique Paths
- Android进阶(三)android httpClient 支持HTTPS的访问方式
- LLRP 提供程序概述
- Markdown入门学习小结
- 取得成本中心组、成本要素组层级的几个BAPI
- 面向对象与面向过程比较
- LeetCode Unique Paths
- linux select多路复用机制
- vmware虚拟机怎么当一台独立电脑?
- 多线程知识
- 2、设计模式之单例模式
- PDF文件如何能转换成excel表格
- POJ 2386 ----- Lake Counting
- yii2 insert
- IOS项目发布过程遇到的元数据问题