[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 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的更多相关文章
- 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 ...
- 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). ...
- Leetcode62.Unique Paths不同路径
一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为"Start" ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在下图中标记为" ...
- [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 ...
- [LeetCode] Unique Paths II 不同的路径之二
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- [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 ...
- Leetcode Unique Paths II
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- Unique Paths II
这题在Unique Paths的基础上增加了一些obstacle的位置,应该说增加的难度不大,但是写的时候对细节的要求多了很多,比如,第一列的初始化会受到之前行的第一列的结果的制约.另外对第一行的初始 ...
- LEETCODE —— Unique Paths II [动态规划 Dynamic Programming]
唯一路径问题II Unique Paths II Follow up for "Unique Paths": Now consider if some obstacles are ...
随机推荐
- 【Struts2学习笔记(11)】对action的输入校验和XML配置方式实现对action的全部方法进行输入校验
在struts2中,我们能够实现对action的全部方法进行校验或者对action的指定方法进行校验. 对于输入校验struts2提供了两种实现方法: 1. 採用手工编写代码实现. 2. 基于XML配 ...
- Java中的工具类和新特性
1:Collections集合框架工具类: /* 集合框架的工具类. Collections:集合框架的工具类.里面定义的都是静态方法. Collections和Collection有什么差别? Co ...
- hdu4289(最小割)
传送门:Control 题意:有n个城市,有个小偷想从其中一个城市逃到另一个城市,警察想要堵截这个小偷,知道了在每个城市堵截的成本,问如何安排在哪些城市堵截可以使得小偷一定会被抓住,而且成本最低. 分 ...
- hdu2569(递推dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2569 分析: f(n),n个珠子的合格数:a(n),n个珠子,最后2个相同的合格数:b(n),n个珠子 ...
- 实习第一天之数据绑定:<%#Eval("PartyName")%>'
1.asp:HyperLink ID="Link" runat="server" Target="_blank" Text='<%#E ...
- RabbitMQ消息队列应用
RabbitMQ消息队列应用 消息通信组件Net分布式系统的核心中间件之一,应用与系统高并发,各个组件之间解耦的依赖的场景.本框架采用消息队列中间件主要应用于两方面:一是解决部分高并发的业务处理:二是 ...
- Linux 单用户模式的使用
在进入系统启动菜单时,选择kernel,输入"e"后进入,在kernel开头的启动项后输入(空格) /single或者 / 1,然后输入"b"重新启动机器,此时 ...
- poj1655(树形dp)
题目链接:http://poj.org/problem?id=1655 题目大意:给一个树,删除其中一个点就会形成一个森林,点的平衡度为删除了这个节点后,所形成多个树,其中组成树的节点最多,节点个数就 ...
- Net分布式系统
Net分布式系统 Net分布式系统之三:Keepalived+LVS+Nginx负载均衡之高可用 摘要: 上一篇写了nginx负载均衡,此篇实现高可用(HA).系统整体设计是采用Nginx做负载均衡, ...
- 图画(txt等一下)实施开放的默认下载的默认浏览器,而不是(Java文本)
在网络上,假设我们超链接地址对应于jpg档,txt档,点击链接,默认浏览器打开这些文件,而不是下载,那么,你如何实现竞争力的默认下载. 1.可通过自己写一个download.jsp来实现 <%@ ...