
The Question
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?
The Anwser
使用动态规划的求解方式。
- 对于第一行,路径只为1;
- 对于第一列,路径只为1;
- 对于i行j列,有两种达到方式:
- 从上方达到;
- 从下方达到。
代码如下
|
|
~Thanks~
By 海天游草~~~2017.4.26




近期评论