Unique Paths

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

Note: m and n will be at most 100.

采用动态规划。

对于格点(i,j)。由于只能从上格点(i-1,j)或左格点(i,j-1)到达,并且两者路径是不重复的

因此path[i][j] = path[i-1][j]+path[i][j-1]

class Solution {
public:
int uniquePaths(int m, int n) {
vector<vector<int> > path(m, vector<int>(n, ));
for(int i = ; i < m; i ++)
{
for(int j = ; j < n; j ++)
{
path[i][j] = path[i-][j] + path[i][j-];
}
}
return path[m-][n-];
}
};

【LeetCode】62. Unique Paths的更多相关文章

  1. 【LeetCode】62. Unique Paths 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/unique-pa ...

  2. 【LeetCode】63. Unique Paths II 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/unique-pa ...

  3. 【一天一道LeetCode】#62. Unique Paths

    一天一道LeetCode系列 (一)题目 A robot is located at the top-left corner of a m x n grid (marked 'Start' in th ...

  4. 【leetcode】62. Uniqe Paths

    题目 https://oj.leetcode.com/problems/unique-paths/   A robot is located at the top-left corner of a m ...

  5. 【LeetCode】63. Unique Paths II

    Unique Paths II Follow up for "Unique Paths": Now consider if some obstacles are added to ...

  6. 【LeetCode】062. Unique Paths

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

  7. 【LeetCode】063. Unique Paths II

    题目: Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. H ...

  8. 【LeetCode】980. Unique Paths III解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 回溯法 日期 题目地址:https://leetco ...

  9. 【leetcode】980. Unique Paths III

    题目如下: On a 2-dimensional grid, there are 4 types of squares: 1 represents the starting square.  Ther ...

随机推荐

  1. JAVA容器-模拟LinkedList实现(双链表)

    概述 LinkedList实质上就是双向链表的拓展的实现,我们将关注一下问题.LinkedList 1.双向链表怎么来实现插入.删除.查询? 2.利用二分法提高查询效率. 3.不同步,线程不安全,需要 ...

  2. Bipolar transistor boosts switcher's current by 12 times

    The circuit in Figure 1 uses a minimal number of external parts to raise the maximum output current ...

  3. How to open a web site with the default web browser in a NEW window

    http://delphi.about.com/cs/adptips2004/a/bltip0504_4.htm When using ShellExecute (as explained in th ...

  4. 禁止body滚动允许div滚动防微信露底

    最近遇到一个需求,页面中只有一个div允许滚动,其他内容不允许滚动. 正常来讲加上 body{height:100%;overflow: hidden;} 应该就阻止页面滚动了.可是很悲催的是手机端并 ...

  5. git ssh key配置

    原文:https://blog.csdn.net/lqlqlq007/article/details/78983879 git clone支持https和git(即ssh)两种方式下载源码:  当使用 ...

  6. [Android Studio] Android Studio中查看类的继承关系

    转载自:http://blog.csdn.net/hyr83960944/article/details/38098091 查看类的继承关系的快捷键F4,在Android Studio常用快捷键这篇文 ...

  7. Guava的使用

    package guava; import java.io.File; import java.io.IOException; import java.util.ArrayList; import j ...

  8. sqlmap使用帮助文档(1)

    当给sqlmap这么一个url的时候,它会: 1.判断可注入的参数 2.判断可以用那种SQL注入技术来注入 3.识别出哪种数据库 4.根据用户选择,读取哪些数据 sqlmap支持五种不同的注入模式: ...

  9. [置顶] Eclipse显示中文 在线安装教程

    准备工作: 1,一个完整的Eclipse软件: 2,加载软件地址:http://download.eclipse.org/technology/babel/update-site/R0.11.0/ke ...

  10. 详解vue父组件传递props异步数据到子组件的问题

    案例一 父组件parent.vue // asyncData为异步获取的数据,想传递给子组件使用 <template> <div> 父组件 <child :child-d ...