[LeetCode] Unique Paths II
来源:互联网 发布:野火微博软件 编辑:程序博客网 时间:2024/05/17 01:34
class Solution {public: int uniquePathsWithObstacles(vector<vector<int> > &obstacleGrid) { int m = obstacleGrid.size(),n = obstacleGrid[0].size(); vector<vector<int> > res(m, vector<int>(n)); res[0][0] = obstacleGrid[0][0] == 0 ? 1 : 0; for(int i = 1;i < n;i ++) res[0][i] = obstacleGrid[0][i] == 0 ? res[0][i - 1] : 0; for(int i = 1;i < m;i ++) res[i][0] = obstacleGrid[i][0] == 0 ? res[i - 1][0] : 0; for(int i = 1;i < m;i ++) for(int j = 1;j < n;j ++) res[i][j] = obstacleGrid[i][j] == 0 ? res[i - 1][j] + res[i][j - 1] : 0; return res[m - 1][n - 1]; }};
0 0
- LeetCode: Unique Paths II
- [Leetcode] Unique Paths II
- LeetCode : Unique Paths II
- [LeetCode] Unique Paths II
- [LeetCode]Unique Paths II
- [leetcode]Unique Paths II
- LeetCode-Unique Paths II
- [leetcode] Unique Paths II
- LeetCode - Unique Paths II
- LeetCode:Unique Paths II
- 【LeetCode】Unique Paths II
- leetcode Unique Paths II
- LeetCode Unique Paths II
- LeetCode | Unique Paths II
- Leetcode: Unique Paths II
- LeetCode Unique Paths II
- Unique Paths II -- LeetCode
- [LeetCode] Unique Paths II
- 微信分享
- html css float left与 float right的使用说明
- iOS沙盒目录结构解析
- Android 3.X中WebView使用ZOOM崩溃的问题
- Android中Bitmap,byte[],Drawable相互转化
- [LeetCode] Unique Paths II
- android自动更新模块实现中知识总结
- Eclipse安装SVN插件
- TextView属性大集中
- 第11周项目2求最大公约数(1.两个数)
- c 整型提升和算数转换
- 安卓环境搭建
- sde for Oracle10g 64bit 删除 SDE用户无法删除的问题
- 结构体的使用