//一维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. Pycharm一直报ImportError: No module named requests

    1.首先检查是否安装了requests l 安装命令:pip install requests如果出现了Requirement already satisfied 代表安装成功 2.系统含有多个版本的 ...

  2. <sourceDirectory>src/main/java</sourceDirectory> mvn 配置 包路径

    <?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven ...

  3. Mercurial

    Contributing Changes http://nginx.org/en/docs/contributing_changes.html Mercurial is used to store s ...

  4. Kafka Consumer接口

    对于kafka的consumer接口,提供两种版本,   high-level 一种high-level版本,比较简单不用关心offset, 会自动的读zookeeper中该Consumer grou ...

  5. Tunnelblick 覆盖安装失败

    公司搬家, jira, sourceTree都链接不上了,发现是VPN断了的原因,需要重新链接VPN Tunnelblick坏掉了,覆盖安装总是提示安装失败,安装超时 nil,搜索一大堆文章, 看了这 ...

  6. php5.6 的curl开启和之前的不太一样了,搞了半天,记录下

    设置电脑环境变量中的->系统变量(注:不是用户变量) 新建 PHP_HOME 值 D:\php /PHP 根目录 Path 增加 ;%PHP_HOME%;%PHP_HOME%\ext       ...

  7. centos LAMP第四部分mysql操作 忘记root密码 skip-innodb 配置慢查询日志 mysql常用操作 mysql常用操作 mysql备份与恢复 第二十二节课

    centos  LAMP第四部分mysql操作  忘记root密码  skip-innodb 配置慢查询日志 mysql常用操作  mysql常用操作 mysql备份与恢复   第二十二节课 mysq ...

  8. 翻译:Addressing tiles: same tile bounds with different indexes

    原文链接:http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/ Addressing tiles: same ...

  9. Java模板模式

    模板类 package com.ietree.designpattern.template; /** * 模板类 * * @author Root */ public abstract class S ...

  10. Gitlab汉化为中文版

    查看当前的gitlab版本号 cat /opt/gitlab/embedded/service/gitlab-rails/VERSION 11.1.4 打开这个网址:https://gitlab.co ...