leetcode 62 C++. Unique Paths
来源:互联网 发布:python 运维框架 编辑:程序博客网 时间:2024/06/05 16:18
解题思路:
典型的DP问题
举个例子,3×3矩阵,到每个格子的方法数是多少?
1 1 1
1 2 3
1 3 6
可以看到到达某个格子的路径数为它上和左的路径数的和, 也就是dp[i][j]=dp[i-1][j]+dp[i][j-1]
class Solution {public: int uniquePaths(int m, int n) { int i,j; if(m==0&&n==0)return 0; if(m==1||n==1)return 1; vector<vector<int>> dp(m,vector<int>(n,1)); for(i=1;i<m;i++){ for(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 C++. Unique Paths
- [leetcode]Unique Paths(C)
- [leetcode 62] Unique Paths
- LeetCode(62): Unique Paths
- [LeetCode 62]Unique Paths
- leetcode || 62、Unique Paths
- Unique Paths - LeetCode 62
- 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
- leetcode 62:Unique Paths
- 【LEETCODE】62-Unique Paths
- 微信公众号开发day1
- 强调在正则中只要单纯用了括号就会有捕获分组保存
- C# 深入理解堆栈、堆在内存中的实现
- Java NIO
- 1、Linux kernel——获取源代码
- leetcode 62 C++. Unique Paths
- 【C#】40. 线程参数传递的三种方法
- 实现Windows数据绑定 上机练习
- Android PopupWindow使用总结
- 基于博创S3C6410l键盘驱动分析与更改
- Kubernetes 高级特性集锦
- linux的进程相关函数简单总结
- system权限创建用户权限进程
- bzoj2160 拉拉队排练