[LeetCode] Unique Paths 解题报告
来源:互联网 发布:东京食尸鬼口罩淘宝 编辑:程序博客网 时间:2024/05/16 19:50
Ranking: **
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).
A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in the diagram below).
How many possible unique paths are there?
Above is a 3 x 7 grid. How many possible unique paths are there?
Note: m and n will be at most 100.
» Solve this problem
[解题思路]
一维DP。 Step[i][j] = Step[i-1][j] + Step[i][j-1];
[Code]
1: int uniquePaths(int m, int n) {
2: vector<int> maxV(n,0);
3: maxV[0]=1;
4: for(int i =0; i< m; i++)
5: {
6: for(int j =1; j<n; j++)
7: {
8: maxV[j] = maxV[j-1] + maxV[j];
9: }
10: }
11: return maxV[n-1];
12: }
0 0
- 【LeetCode】Unique Paths 解题报告
- [LeetCode] Unique Paths 解题报告
- [LeetCode]Unique Paths II, 解题报告
- 【LeetCode】Unique Paths II 解题报告
- LeetCode 62 Unique Paths 解题报告
- [leetcode] 62. Unique Paths 解题报告
- [leetcode] 63. Unique Paths II 解题报告
- [LeetCode] Unique Paths II 解题报告
- leetcode解题报告:62. Unique Paths
- [Leetcode] 62. Unique Paths 解题报告
- [Leetcode] 63. Unique Paths II 解题报告
- 【LeetCode】62.Unique Paths解题报告
- Leetcode #62. Unique Paths 路径搜寻 解题报告
- Leetcode 63. Unique Paths II 路径搜寻2 解题报告
- leetcode解题方案--062--Unique Paths
- leetcode解题方案--063--Unique Paths II
- leetcode Unique Paths && Unique Paths
- LeetCode-Binary Tree Paths -解题报告
- [LeetCode] Symmetric Tree 解题报告
- [LeetCode] Text Justification 解题报告
- [LeetCode] Trapping Rain Water 解题报告
- android中的AIDL进程间通信
- [LeetCode] Triangle 解题报告
- [LeetCode] Unique Paths 解题报告
- [LeetCode] Unique Paths II 解题报告
- python生成随机数组
- [LeetCode] Valid Parentheses 解题报告
- MSSQL Server数据的完整性
- MVP模式在android的使用
- [LeetCode] Valid Sudoku 解题报告
- [LeetCode] Validate Binary Search Tree 解题报告
- [LeetCode] Wildcard Matching, Solution