//一维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的更多相关文章

  1. [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 ...

  2. Java实现 LeetCode 63 不同路径 II(二)

    63. 不同路径 II 一个机器人位于一个 m x n 网格的左上角 (起始点在下图中标记为"Start" ). 机器人每次只能向下或者向右移动一步.机器人试图达到网格的右下角(在 ...

  3. LeetCode 63. Unique Path II(所有不同路径之二)

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  4. [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 ...

  5. LeetCode: 63. Unique Paths II(Medium)

    1. 原题链接 https://leetcode.com/problems/unique-paths-ii/description/

  6. 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). ...

  7. leetcode 63. Unique Paths II

    Follow up for "Unique Paths": Now consider if some obstacles are added to the grids. How m ...

  8. LeetCode(63)-First Bad Version

    题目: You are a product manager and currently leading a team to develop a new product. Unfortunately, ...

  9. leetcode 63 不同的路径2

    描述: 从左上角走到右下角,中间可能有若干阻碍: 题目给出一个矩阵,0表示可以走,1表示有障碍. 解决: 思路同第一题,只是如果上面或左边有障碍,自身不一定能走,注意些边界条件即可,复杂度仍是m*n. ...

随机推荐

  1. HDU_3486_Interviewe

    Interviewe Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  2. Information:java: Errors occurred while compiling module 'spring'

    IntellJ Idea遇到Errors occurred while compiling module的解决方法 - sully2008的专栏 - CSDN博客 https://blog.csdn. ...

  3. django-models的get与filter

    为了说明它们两者的区别定义2个models class Student(models.Model):name = models.CharField('姓名', max_length=20, defau ...

  4. 爬虫Scrapy框架

    安装scrapy 在安装过程中报错:解决方案 通过在https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted,然后下载: CP后是python 版本,32 ...

  5. (转) 密码学中的“盐值 Salt”

    为什么要在密码里加点“盐” 盐(Salt) 在密码学中,是指通过在密码任意固定位置插入特定的字符串,让散列后的结果和使用原始密码的散列结果不相符,这种过程称之为“加盐”. 以上这句话是维基百科上对于 ...

  6. (转)Springboot+shiro配置笔记+错误小结

    springboot不像springmvc,它没有xml配置文件,那该如何配置shiro呢,其实也不难,用java代码+注解来解决这个问题.仅以此篇记录我对shiro的学习,如有对过客造成不便,实在抱 ...

  7. ubuntu16.04 安装指定版本Node,升级npm到指定版本

    一.安装配置Node 1.下载(64位系统) wget https://nodejs.org/download/release/v10.1.0/node-v10.1.0-linux-x64.tar.g ...

  8. web http协议

    http协议超文本传输协议 http协议是IOS七层协议的应用层,是基于TCP/IP协议的,为什么还要多一个协议了,其实利用TCP协议也是可以的,但是TCP三次握手后是一直保持连接的,如果单单是c/s ...

  9. python学习之【16】网络编程

    主题 客户端/服务器架构 套接字:通信终点 套接字地址 面向连接与无连接套接字 Python中的网络编程 SOCKET模块 套接字对象方法 TCP/IP客户端和服务器 UDP/IP客户端和服务器 So ...

  10. ASP.NET之报表--RDLC(一)---附源码

    听同事介绍到RDLC,之前有了解过报表,但是确实没什么放在心上.最近有空,就研究下了. 一.RDLC实现 1.步骤 (1)首先新建一个项目RDLCDemo (2)新建一个DataSet数据集,并且绑定 ...