LeetCode之旅(31)
来源:互联网 发布:java 可变数组 编辑:程序博客网 时间:2024/06/06 03:42
Unique Paths
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?
很经典的题目,不能用递归,会超时
class Solution {public: int uniquePaths(int m, int n) { int *a = new int [m*n]; for (int i=0; i<n; i++) { for (int j=0; j<m; j++) { if (i==0 || j==0) a[m*i+j] = 1; else a[m*i+j] = a[m*i+j-1] + a[m*(i-1)+j]; } } return a[m*n-1]; }};
0 0
- LeetCode之旅(31)
- LeetCode之旅(2)
- LeetCode之旅(3)
- LeetCode之旅(4)
- LeetCode之旅(5)
- LeetCode之旅(6)
- LeetCode之旅(7)
- LeetCode之旅(8)
- LeetCode之旅(9)
- LeetCode之旅(10)
- LeetCode之旅(12)
- LeetCode之旅(13)
- LeetCode之旅(14)
- LeetCode之旅(15)
- LeetCode之旅(16)
- LeetCode之旅(17)
- LeetCode之旅(18)
- LeetCode之旅(19)
- 【度学堂】百度QA的特点与核心价值
- 图片的上传
- CF 461 A Appleman and Toastman
- poj 1321(棋盘问题)
- GCC installation on Android
- LeetCode之旅(31)
- 【51tesing】测试者的价值
- 关于指针的常见疑惑
- javascript小记
- php-session-1218
- [leetcode] Container With Most Water
- 【度学堂】软件测试之bug分析定位技巧
- Linux的基本命令
- Service