//一维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. CentOS安装Nginx-1.6.2+安全配置+性能配置

    注:以下所有操作均在CentOS 6.5 x86_64位系统下完成. #准备工作# 在安装Nginx之前,请确保已经使用yum安装了pcre等基础组件,具体见<CentOS安装LNMP环境的基础 ...

  2. HDU Today---hdu2112(最短路-_-坑在是无向图)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2112 spfa或者迪杰斯特拉都可以 注意公交车是有来回的--- #include <iostre ...

  3. 《图解HTTP》书摘

    图解HTTP 上野宣.于均良 1.3 网络基础 TCP/IP 2016-03-03 相互通信,双方就必须基于相同的方法.比如,如何探测到通信目标.由哪一边先发起通信.使用哪种语言进行通信.怎样结束通信 ...

  4. H5上传压缩图片

    看这个,比较全的 https://github.com/mhbseal/html5ImgCompress ,几乎所有痛点都解决了! PC上传图片 基本结构 form[enctype="mul ...

  5. 第1章 1.7计算机网络概述--理解OSI参考模型分层思想

    OSI七层模型,知识参考理论. 分层标准的好处: 1.不同的硬件生产商生产的硬件产品,连通后就可以用了,有助于互联网发展. 2.分层,分成不同的模块,某一层的变化,不会影响其他层.如:IPv4改为IP ...

  6. Yahoo Programming Contest 2019

    A - Anti-Adjacency 签. #include <bits/stdc++.h> using namespace std; int main() { int n, k; whi ...

  7. Java Character 类

    Character 类用于对单个字符进行操作. Character 类在对象中包装一个基本类型 char 的值 实例 char ch = 'a'; // Unicode 字符表示形式 char uni ...

  8. python遗留问题

    def assert_element_in_page_source(s): print type(s) print s #assert s in driver.page_sourcecommand=' ...

  9. C++ string和C风格字符串

    https://msdn.microsoft.com/en-us/library/syxtdd4f.aspx#basic_string__replace If you need to convert ...

  10. Tomcat启动报错:StandardServer.await: create[8005] java.net.BindException: Cannot assign requested address

    Tomcat启动报错:StandardServer.await: create[8005] java.net.BindException: Cannot assign requested addres ...