标签:
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.
Array Dynamic Programming
#include<iostream>
#include <vector>
using namespace std;
#define MAXSIZE 110
int uniquePaths(int m, int n) {
int ary1[MAXSIZE][MAXSIZE];
ary1[m][n]=1;
for(int i=m;i>=1;i--)
for(int j=n;j>=1;j--)
{
if(i==m||j==n)
ary1[i][j]=1;
else
ary1[i][j]=ary1[i+1][j]+ary1[i][j+1];
}
return ary1[1][1];
}
int main()
{
}
leetcode_62题——Unique Paths (动态规划)
标签:
原文地址:http://www.cnblogs.com/yanliang12138/p/4546543.html