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. 使用 Node.js 搭建微服务网关

    目录 Node.js 是什么 安装 node.js Node.js 入门 Node.js 应用场景 npm 镜像 使用 Node.js 搭建微服务网关 什么是微服务架构 使用 Node.js 实现反向 ...

  2. JS中深浅拷贝 函数封装代码

    一.了解 基本数据类型保存在栈内存中,按值访问,引用数据类型保存在堆内存中,按址访问. 二.浅拷贝 浅拷贝只是复制了指向某个对象的指针,而不是复制对象本身,新旧对象其实是同一内存地址的数据,修改其中一 ...

  3. python-状态模式

    源码地址:https://github.com/weilanhanf/PythonDesignPatterns 说明: 在软件开发过程中,各种应用程序可能会根据不同的情况做出不同的处理.最直接的方案就 ...

  4. h5新增加的存储方法

    h4中使用的cookie把用户信息保存在客户端浏览器,但是它受到很多限制. 大小:最多能存储4k 带宽:它是随着http请求一起发送到服务器的,因此浪费一部分的带宽. 复杂度:操作复杂. h5新增加了 ...

  5. 【代码笔记】iOS-在导航栏中显示等待对话框

    一,效果图. 二,代码. ViewController.m #import "ViewController.h" @interface ViewController () @end ...

  6. 【读书笔记】iOS-网络-Web Service协议与风格

    协议指的是在与其它系统交换结构化信息时所要遵循的一套格式,过程与规则.此外,协议定义了在传输过程中所要使用的数据格式.这样,接收系统就能正确地解释结构化信息并做出正应的回应. 1,简单对象访问协议. ...

  7. HTML:target=_blank、target=_top、target=_parent、target=_self 的区别

    HTML:target=_blank.target=_top.target=_parent.target=_self 的区别 _blank 在新窗口中打开链接_parent 在父窗体中打开链接_sel ...

  8. [SSRS / RV] (.rdlc报表)冻结表头,固定行列标题

    转自:https://blog.csdn.net/dietime1943/article/details/72846171?utm_source=blogxgwz9 Reporting Service ...

  9. MySQL常用查询语句积累

    >>MySQL某列插入递增值 SET @i := 100; UPDATE auge_item_classification SET c_code=(@i:=(@i+1)); >> ...

  10. post请求的四种数据格式

    1.application/json:这是最常见的 json 格式:{"input1":"xxx","input2":"ooo&q ...