leetcode 62. Unique Paths
来源:互联网 发布:端口打开失败怎么回事 编辑:程序博客网 时间:2024/04/29 08:13
题意
在一个矩阵中只能向右和向下走,问从起点到终点有多少种走法
题解
使用动态规划。以点(i,j)为终点的路径数 =(i - 1,j)为终点的路径数 + (i,j - 1)为终点的路径数。
代码
class Solution {public: int uniquePaths(int m, int n) { int dp[m][n]; dp[0][0] = 1; for(int j = 0; j < n; j++) dp[0][j] = 1; for(int i = 0; i < m; i++) dp[i][0] = 1; for(int i = 1; i < m; i++) { for(int j = 1; j < n; j++) { dp[i][j] = dp[i - 1][j] + dp[i][j - 1]; } } return dp[m - 1][n - 1]; }};
0 0
- [LeetCode]62.Unique Paths
- LeetCode --- 62. Unique Paths
- LeetCode 62.Unique Paths
- [Leetcode] 62. Unique Paths
- [leetcode] 62.Unique Paths
- [leetcode] 62.Unique Paths
- leetcode 62. Unique Paths
- Leetcode 62. Unique Paths
- [leetcode] 62. Unique Paths
- 62. Unique Paths LeetCode
- [LeetCode]62. Unique Paths
- 【LeetCOde】62. Unique Paths
- [LeetCode]62. Unique Paths
- leetcode 62. Unique Paths
- LeetCode 62. Unique Paths
- LeetCode *** 62. Unique Paths
- leetcode 62. Unique Paths
- Leetcode:62. Unique Paths
- 基因数据处理19之BWA匹配算法串产生、匹配、评价等整体流程
- LaTeX在MATLAB上的使用
- VS快捷键,非常实用!
- 时间格式化函数--strftime
- 使用notepad++ 让word里面的代码高亮
- leetcode 62. Unique Paths
- Swift开发:弹框(UIAlertController)
- 116. Populating Next Right Pointers in Each Node
- iOS小技巧 - ARC与非ARC的混合开发
- centos7修改文件写权限
- 【NOIP2015模拟11.2晚】我的天
- iOS UITableViewCell重用问题
- linux下网站数据和数据库的备份与恢复
- c++ 编程拾贝(三)