Friday, October 3, 2014

Unique Paths

Problem

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?

Idea

DP的思路解, a[i][j]表示在第i,j个方格时有多少中情况,第0行和第0列全都设成0, a[1][1]=1 以后每项a[i][j] = a[i-1][j]+a[i][j-1]

Solution


No comments:

Post a Comment