Unique Path II
来源:互联网 发布:易语言编程教学 编辑:程序博客网 时间:2024/05/18 01:01
同Leetcode No.64 Minimum Path一样,可以使用滚动矩阵,来减小Space Complexity。
public class Solution { public int uniquePathsWithObstacles(int[][] obstacleGrid) { if (obstacleGrid == null || obstacleGrid.length == 0 || obstacleGrid.length == 0) { return -1; } int row = obstacleGrid.length; int col = obstacleGrid[0].length; int[] path = new int[col]; for (int j = 0; j < col; j++) { if (obstacleGrid[0][j] == 0) { path[j] = 1; } else { break; } } for (int i = 1; i < row; i++) { if (obstacleGrid[i][0] == 1) { path[0] = 0; } for (int j = 1; j < col; j++) { if (obstacleGrid[i][j] == 0) { path[j] += path[j - 1]; } else { path[j] = 0; } } } return path[col - 1]; }}
0 0
- Unique Path II
- [Leetcode]Unique Path II
- 10.3 Unique Path II
- [leetcode] Unique Path II
- Unique Path II--LeetCode
- Unique path ii
- Unique Path II
- [Leetcode]Unique Path II
- Unique Path II
- Leetcode Unique Path II
- LeetCode 62. Unique Path II
- [Leetcode] 63. Unique Path II
- Unique Paths I,II, Minimum Path Sum
- 63. Unique Path II Leetcode Python
- [leetcode题后感]unique path I、 II
- [LeetCode] Unique Paths、Unique Paths II、Minimum Path Sum
- leetcode Unique Paths & Unique Paths II & Minimum Path Sum
- Leetcode: Unique Path I & II, Minimum Path Sum, Triangle
- jQuery 学习笔记
- linux bash shell中,单引号、 双引号,反引号(``)的区别及各种括号的区别
- Dijkstra模板
- 使用移位操作符实现无符号整数位反转
- KMP 算法完整版
- Unique Path II
- UVA 12437 Kisu Pari Na 2
- 计算机字符编码
- 安装Tomcat,过程中需要配置的环境变量及遇到的问题
- HDU5326-Work (建反图,遍历)
- IOS开发概述-09.UIController和控制器的View
- python内置函数(三)
- linux中文显示乱码问题
- 【进阶android】Volley源码分析——Volley的工具【StringRequest】