LeetCode 62. Unique Paths
2016-07-22 02:00
375 查看
2. Unique Paths
My Submissions QuestionEditorial Solution
Total Accepted: 84185 Total Submissions: 233521 Difficulty: Medium
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.
My Submissions QuestionEditorial Solution
Total Accepted: 84185 Total Submissions: 233521 Difficulty: Medium
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.
class Solution { public: int uniquePaths(int m, int n) { int a[100][100]; for(int i = 0; i < m; i++) { for(int j = 0; j < n; j++) { if(i == 0 || j == 0) a[i][j] = 1; else a[i][j] = a[i - 1][j] + a[i][j - 1]; } } return a[m - 1][n - 1]; } };
相关文章推荐
- LeetCode 225. Implement Stack using Queues
- Android适配——采用Values-dpi-wSize X hSize 模式,并分析原理
- LeetCode 303. Range Sum Query – Immutable
- LeetCode 347. Top K Frequent Elements
- LeetCode 63. Unique Paths II
- iOS 分类之UIColor+Hex
- LeetCode 96. Unique Binary Search Trees
- LeetCode 300. Longest Increasing Subsequence
- LeetCode 304. Range Sum Query 2D – Immutable
- UITableView修改索引的方法
- ionic生成apk使用build命令下载gradle-2.2.1-all.zip卡,解决方案
- LeetCode 51. N-Queens
- LeetCode 52. N-Queens II
- php学习笔记之require()和include()
- HashMap按value的顺序输出
- 用vue创建hello world,不用再担心显示message了
- 使用PortableBasemapServer 和 terrabuilder 制作MPT
- Lucene3.X中的自定义评分机制
- Lucene4.X中的自定义评分机制
- 【Arduino官方教程】数字处理示例(六):音调键盘