题目:

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.

分类:Array ,DP

代码:

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

[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). The ...

  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. 【ArcGIS 10.2新特性】ArcGIS 10.2 for Server常见问题

    1.ArcGIS 10.2有无测试版程序? 10.2没有正式的测试版程序,但是我们计划发布两个早期cuts软件给国际经销商.选中的用户和合作伙伴. 2.微软Azure云的ArcGIS forServe ...

  2. RCP开发中错误:java.lang.RuntimeException: WARNING: Prevented recursive attempt to activate part...

    在做RCP的eclipse插件开发时,启动管理软件界面时,总是报如下错误 : !ENTRY org.eclipse.ui.workbench 4 0 2012-05-25 18:44:21.306 ! ...

  3. hdu1690 Bus System (dijkstra)

    Problem Description Because of the huge population of China, public transportation is very important ...

  4. ZOJ 3635 Cinema in Akiba(线段树)

    Cinema in Akiba (CIA) is a small but very popular cinema in Akihabara. Every night the cinema is ful ...

  5. Java程序猿学习当中各个阶段的建议

    回答阿里社招面试如何准备,顺便谈谈对于Java程序猿学习当中各个阶段的建议   引言 其实本来真的没打算写这篇文章,主要是LZ得记忆力不是很好,不像一些记忆力强的人,面试完以后,几乎能把自己和面试官的 ...

  6. tomcat 下部署 php

    由于需要测试一个PHP的环境.故记录此处. 环境 OS:win8.1 up1 64bit tomcat :8.0.14 64bit php:php-5.6.2-Win32-VC11-x64.zip 将 ...

  7. c#抓取动态页面WebBrowser

    在ajax横行的年代,很多网页的内容都是动态加载的,而我们的小爬虫抓取的仅仅是web服务器返回给我们的html,这其中就 跳过了js加载的部分,也就是说爬虫抓取的网页是残缺的,不完整的,下面可以看下博 ...

  8. 深入java并发Lock一

    java有像syncronized这种内置锁,但为什么还须要lock这种外置锁? 性能并非选择syncronized或者lock的原因,jdk6中syncronized的性能已经与lock相差不大. ...

  9. HTML5拖动画布/拖放

    <!DOCTYPE HTML> <html> <head> <script type="text/javascript"> func ...

  10. FUDCon - FedoraProject

    FUDCon - FedoraProject FUDCon: Fedora Users and Developers Conference FUD: An acronym for Fear, Unce ...