//一维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. SLF4J其实只是一个门面服务而已,他并不是真正的日志框架,真正的日志的输出相关的实现还是要依赖Log4j、logback等日志框架的。

    小结: 1.加层: 每一种日志框架都有自己单独的API,要使用对应的框架就要使用其对应的API,这就大大的增加应用程序代码对于日志框架的耦合性. 为了解决这个问题,就是在日志框架和应用程序之间架设一个 ...

  2. Wireshark分析之TCP协议(二)

    (1)TCP首部格式 源端口:   用来传输数据报的端口 目标端口: 数据包将要发送到的端口 序号: 用来表示一个TCP片段.这个值用来表示数据流中的部分数据没有丢失 确认号:  表示通信中希望从另一 ...

  3. 'ascii' codec can't decode byte 0xc4 in position 27: ordinal not in range(128)

    This error happens when I try to run d:\linux\linuxkernel\android\内核\blog\BlogBackup(v1.1)source\htm ...

  4. 003-spring cache-JCache (JSR-107) annotations

    参看地址:https://docs.spring.io/spring/docs/current/spring-framework-reference/integration.html#cache-js ...

  5. mysql中的多行查询结果合并成一个(转)

    SELECT GROUP_CONCAT(md.data1) FROM DATA md,contacts cc WHERE md.conskey=cc.id AND md.mimetype_id= 5 ...

  6. PAT 1055 The World's Richest[排序][如何不超时]

    1055 The World's Richest(25 分) Forbes magazine publishes every year its list of billionaires based o ...

  7. Codeforces Round #523 (Div. 2) Solution

    A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (sc ...

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

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

  9. python uwsgi报错epoll_ctl(): Bad file descriptor

    今天安装了uwsgi+supervisord+nginx,一直访问不了 直接启动uwsgi使用nginx访问,查看有大量报错:epoll_ctl(): Bad file descriptor [cor ...

  10. Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project

    本文转自:http://www.phperz.com/article/14/1205/39544.html 本文向大家讲解了Myeclipse错误:Errors occurred during the ...