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. 2015编程之美 初赛第一场C题 质数相关 二分图的最大匹配

    质数相关 Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://hihocoder.com/contest/msbop2015round2a/prob ...

  2. Unity快捷键总结

    Shift+Alt+A  物体快速激活 Ctrl+P 开始 Ctrl+Shift+P 暂停 Ctrl+B  编译并运行 Z  Pivot/Center切换 X Local/Global切换

  3. TCP/IP具体解释--TCP/UDP优化设置总结&amp; MTU的相关介绍

    首先要看TCP/IP协议,涉及到四层:链路层,网络层.传输层,应用层. 当中以太网(Ethernet)的数据帧在链路层 IP包在网络层 TCP或UDP包在传输层 TCP或UDP中的数据(Data)在应 ...

  4. 【mybatis】mysql级联更新两个表或多张表的数据

    例如 info表和relation表有关联,现在要在一个sql语句中同时级联更新两张表的数据 update security_code_info info LEFT JOIN security_cod ...

  5. 分享一个基于 Node.js 的 Web 开发框架 - Nokitjs

    简介 Nokit 是一个简单易用的基于 Nodejs 的 Web 开发框架,默认提供了 MVC / NSP / RESTful 等支持,并提供对应项目模板.管理工具. 资源 GitHub https: ...

  6. 关于TagHelper的那些事情——自定义TagHelper(格式化输出、依赖注入使用)

    自定义TagHelper的最后一步就是在Process方法或ProcessAsync方法中添加展现代码.熟悉WebControl开发的朋友都知道Render方法,在这个方法中会添加展现的Html元素和 ...

  7. ThreadLocal实现session中用户信息 的线程间共享

    转载自:http://blog.sina.com.cn/s/blog_4b5bc01101013gok.html ThreadLocal并不难理解,我总结的最简单的理解就是: ThreadLocal像 ...

  8. CSS 中的强制换行和禁止换行

    强制换行       1.word-break: break-all;       只对英文起作用,以字母作为换行依据.       2.word-wrap: break-word;   只对英文起作 ...

  9. Voice Commands (VCD) Cortana 微软小娜示例

    Cortana 样品 您可以创建自定义功能Cortana使用Cortana技能装备或遗留的声音命令(VCD)平台. 在这里,你可以找到相关的样品: Cortana技能装备 目前Cortana技巧是建立 ...

  10. PHP封装成应用程序的三个方案

    大概有三个解决方案吧. 1 如果你精通PHP,你可以看看这个网站:http://gtk.php.net/ 很明显,这个网站介绍了啥是GTK,你可以构件跨平台的图形化应用程序,当然你要再学一门语言,去掌 ...