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-];
    }
};

leetcode62—Unique Paths的更多相关文章

  1. [LeetCode62]Unique Paths

    题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  2. leetcode-62. Unique Paths · DP + vector

    题面 A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  3. Leetcode62.Unique Paths不同路径

    一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为"Start" ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为" ...

  4. [Swift]LeetCode62. 不同路径 | Unique Paths

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...

  5. [LeetCode] Unique Paths II 不同的路径之二

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  6. [LeetCode] Unique Paths 不同的路径

    A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...

  7. Leetcode Unique Paths II

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  8. Unique Paths II

    这题在Unique Paths的基础上增加了一些obstacle的位置,应该说增加的难度不大,但是写的时候对细节的要求多了很多,比如,第一列的初始化会受到之前行的第一列的结果的制约.另外对第一行的初始 ...

  9. LEETCODE —— Unique Paths II [动态规划 Dynamic Programming]

    唯一路径问题II Unique Paths II Follow up for "Unique Paths": Now consider if some obstacles are ...

随机推荐

  1. Inviting Friends(hdu3244 && zoj3187)完全背包+二分

    Inviting Friends Time Limit: 1 Second Memory Limit: 32768 KB You want to hold a birthday party, invi ...

  2. Angular4.x 自定义搜索组件

    Angular4 随笔(三)  ——自定义搜索组件 1.简介 本组件主要是实现了搜索功能,主要是通过父子组件传值实现. 基本逻辑: 1.创建一个搜索组件,如:ng g component  searc ...

  3. js-ES6学习笔记-Class(2)

    1.与函数一样,类也可以使用表达式的形式定义. const MyClass = class Me { getClassName() { return Me.name; } }; 这个类的名字是MyCl ...

  4. CentOS7安装maven3.6.1

    1.下载maven的tar.gz安装包 2.移到centos7中并解压 tar -xzvf maven.tar.gz 3.开始配置maven环境变量,通过命令 vim /etc/profile 4.配 ...

  5. 活字格Web应用平台学习笔记3-显示数据列表

    活字格第二课的目标,用活字格创建一个简单的在线数据管理系统. 看下设计界面.刚开始跟着点,有点懵圈,到做完,回忆了一下,其实就是先建一张表,然后,把表和页面联系起来,即在页面中划出一些区域,和表的字段 ...

  6. 禅道项目管理软件 为提交Bug页面设置bug必填字段

    为提交Bug页面设置bug必填字段 by:授客 QQ:1033553122 测试环境: 禅道项目管理软件7.1.stable版本 注:仅适合windows版 步骤1.找到xampp\zentao\mo ...

  7. maven 学习笔记--简介

    1.什么是maven Maven是一个服务于基于java平台的项目构建.依赖管理和项目信息管理. 2:什么是构建,maven是个优秀构建工具? (1)构建(bulid):对代码的进行编译.运行单元测试 ...

  8. keystone令牌三种生成方式

    keystone认证方式:UUID.PKI.Fernet; 知识点复习: 通俗的讲,token 是用户的一种凭证,需拿正确的用户名/密码向 Keystone 申请才能得到.如果用户每次都采用用户名/密 ...

  9. Pytest+Allure环境的搭建

    参考博客 测试报告解释 pytest+allurre进阶 1. pytest的安装: 1.1. windows下: pip install pytest 1.2. linux下: pip instal ...

  10. 容器监控—阿里云&容器内部服务监控

    目前Docker的使用越来越离不开对容器的监控,阿里云最近上线了容器服务,不但提供了核心的容器和宿主机监控能力,而且支持集成 Cloud Insight 监控,下面会介绍如何集成. 首先介绍一下阿里云 ...