不同的路径 II
2024-09-22 15:57:02
class Solution {
public:
/**
* @param obstacleGrid: A list of lists of integers
* @return: An integer
*/
int uniquePathsWithObstacles(vector<vector<int> > &obstacleGrid) {
// write your code here
int m = obstacleGrid.size();
if(m==) return ;
int n = obstacleGrid[].size();
int a[m][n];
int temp=;
for(int i=;i<m;++i){
a[i][]=;
if(obstacleGrid[i][]==){
temp = i;
a[i][]=;
}
if(i>=temp)
a[i][]=;
}
temp = ;
for(int j=;j<n;++j){
a[][j]=;
if(obstacleGrid[][j]==){
temp = j;
a[][j]=;
}
if(j>=temp)
a[][j]=;
}
for(int i =;i < m;++i){
for(int j =;j<n;++j){
a[i][j]=a[i-][j]+a[i][j-];
if(obstacleGrid[i][j]==)
a[i][j]=;
}
}
return a[m-][n-];
}
};
最新文章
- secureCRT远程登录工具的颜色配置(转载)
- 实现android手机来电拦截系统页面弹出自定义页面特效
- eclipse的快捷操作(转)
- 如何解决CRUD操作中与业务无关的字段赋值
- CentOS7安装Nginx-1.9.9+PHP5.6
- Photo Kit 框架
- 关于QT安装的一些心得(QT551, VS2013)项目开发配置,以及项目结构分析
- Android 学习笔记之Volley(七)实现Json数据加载和解析...
- C# XML 文档注释文件格式
- Android Studio中Gradle使用详解
- 自主创建tcpdump/wireshark pcap文件
- wso2esb源码编译总结
- HDU 2815 Mod Tree 离散对数 扩张Baby Step Giant Step算法
- 解决背景图文字盖住html里面的dom元素
- topcoder srm 712 div1
- Cannot subclass final class class com.sun.proxy.$Proxy
- .Net WEB 程序员需要掌握的技能
- JSON转换的原创工具类
- remote link Centos6.6 Horrible Slow
- asp,对待绑定数据加序号列(DataSet)