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 7 x 3 grid. How many possible unique paths are there?

Note: m and n will be at most 100.

Example 1:

Input: m = 3, n = 2
Output: 3
Explanation:
From the top-left corner, there are a total of 3 ways to reach the bottom-right corner:
1. Right -> Right -> Down
2. Right -> Down -> Right
3. Down -> Right -> Right

Example 2:

Input: m = 7, n = 3
Output: 28
想法:采用动态规划,确立状态转移表达式f(m,n)=f(m-1,n)+f(n-1,m)表示可能性。
class Solution {
public:
    int uniquePaths(int m, int n) {
        int result[m][n];
         ; i < m ; i++){
             ; j < n ; j++){
                 == i ||  == j){
                    result[i][j] = ;
                    continue;
                }
                result[i][j] = result[i-][j] + result[i][j-];
            }
        }
        ][n-];
    }
};

最新文章

  1. 微信小程序小技巧系列《二》show内容展示,上传文件编码问题
  2. 如何解决google ping不通的问题。
  3. 通过编程发现Java死锁
  4. PHPRPC jsp发布服务
  5. 关于Redis的启动过程
  6. centos升级mysql至5.7
  7. jQuery图片无缝滚动JS代码ul/li结构
  8. 【面试题043】n个骰子的点数
  9. 在同一台机器上让Microsoft SQL Server 2000/ SQL2005/ SQL2008共存
  10. apache php gzip压缩输出的实现方法
  11. char图表
  12. linux中BASH_SOURCE[0]
  13. Visual Studio跨平台开发实战(5) - Xamarin Android多页面应用程式开发
  14. Java不走弯路教程(3.用户验证与文件内容查询)
  15. java反射获取Object的属性和值
  16. 公众号第三方平台开发 教程六 代公众号使用JS SDK说明
  17. js 算數(Math)對象
  18. linux中cmake语法的学习
  19. 廖雪峰Java1-2程序基础-9数组
  20. 一个Form表单多个Submit提交按钮!实现提交不同的参数!

热门文章

  1. Java - Stack源码解析
  2. 你不知道的JavasScript上篇&#183;第五章&#183;原型&#183;下
  3. bzoj P5016[Snoi2017]一个简单的询问——solution
  4. BFC(块状格式化上下文)
  5. Postman&#160;Postman测试接口之JSON结构化数据提交
  6. 闲聊jQuery(一)
  7. web调试-禁止/清空chrome页面缓存
  8. The current identity ( XXXX) does not have write access to ‘C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files’.解决办法
  9. C#读取AD域用户信息
  10. 通用视图-分开处理GET、POST请求