Leetcode 63
//一维dp还是比较难写的
class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
int m = obstacleGrid[].size();
int n = obstacleGrid.size();
vector<int> dp(m,);
for(int j=;j < m;j++){
if(obstacleGrid[][j] == ){
for(int i=j;i < m;i++)
dp[i] = ;
break;
}
}
for(int i=;i < n;i++){
if(obstacleGrid[i][] == ){
dp[] = ;
}
for(int j=;j < m;j++){
dp[j] = dp[j] + dp[j-];
if(obstacleGrid[i][j] == ){
dp[j] = ;
}
}
} return dp[m-]; }
};
Leetcode 63的更多相关文章
- [LeetCode] 63. Unique Paths II 不同的路径之二
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...
- Java实现 LeetCode 63 不同路径 II(二)
63. 不同路径 II 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为"Start" ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在 ...
- LeetCode 63. Unique Path II(所有不同路径之二)
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- [LeetCode] 63. Unique Paths II_ Medium tag: Dynamic Programming
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The ...
- LeetCode: 63. Unique Paths II(Medium)
1. 原题链接 https://leetcode.com/problems/unique-paths-ii/description/
- LeetCode 63. Unique Paths II不同路径 II (C++/Java)
题目: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...
- leetcode 63. Unique Paths II
Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...
- LeetCode(63)-First Bad Version
题目: You are a product manager and currently leading a team to develop a new product. Unfortunately, ...
- leetcode 63 不同的路径2
描述: 从左上角走到右下角,中间可能有若干阻碍: 题目给出一个矩阵,0表示可以走,1表示有障碍. 解决: 思路同第一题,只是如果上面或左边有障碍,自身不一定能走,注意些边界条件即可,复杂度仍是m*n. ...
随机推荐
- gcc windows版本
MingW 分 32位和64位版本:下载地址分别如下: http://sourceforge.net/projects/mingw/ http://sourceforge.net/projects/m ...
- 由于dns服务为启动导致的GI集群启动故障
1.物业由于突然断电导致grid集群重新启动后rac数据库无法正常启动,对集群进行检查,结果如下,发现其中有4个数据库状态为instance shutdown.[root@node1 ~]# su - ...
- 如何在window的location使用target
在页面中window的location跳转时,指定页面在框架中跳转 1. 如果你要让最顶层的框架跳转,就是整个页面,相当于用traget指向顶层 window.top.location = & ...
- stark - 分页、search、actions
一.分页 效果图 知识点 1.分页 {{ showlist.pagination.page_html|safe }} 2.page.py class Pagination(object): def _ ...
- [Axiom3D]第一个Axiom3D程序
Axiom3D程序的基本渲染流程 #region Namespace Declarations using System; using System.Linq; using Axiom.Core; u ...
- 基于Python的交互式可视化工具 [转]
前几天发现一个可视化工具Dash,当看到它的交互式效果后突然就觉得眼前一亮.早就想写出来分享给大家,今天利用睡前一点时间发出来,希望能给有需要的朋友带来一点帮助或者多一个参考. Dash介绍 在Pyt ...
- python技巧总结之set、日志、rsa加密
一.日志模块logging模块调用 1.日志模块使用原理 #!/usr/bin/python # -*- coding:utf-8 -*- import logging # 方式一: "&q ...
- mysql key index区别
看似有差不多的作用,加了Key的表与建立了Index的表,都可以进行快速的数据查询.他们之间的区别在于处于不同的层面上. Key即键值,是关系模型理论中的一部份,比如有主键(Primary Key), ...
- java Pattern(正则)类
Pattern的静态方法matches 用于快速匹配字符串,该方法适合用于只匹配一次,且匹配全部字符串. Boolean b=Pattern.matches("^((13[0-9])|(15 ...
- fiddler抓包HTTPS配置及代理设置
使用fiddler抓包过程中遇到一系列的问题,浪费了大半天时间~~~写下解决办法 按照网上方法配置之后还是无法抓到cookies提示各种证书错误 1.卸载fiddler重新安装,设置 2.设置步骤 ( ...