当前位置:网站首页>63. different paths II
63. different paths II
2022-06-13 00:11:00 【anieoo】
Original link :63. Different paths II
solution:
The standard dp, Just add the judgment of obstacles during initialization and circulation
class Solution {
public:
int uniquePathsWithObstacles(vector<vector<int>>& obstacleGrid) {
int m = obstacleGrid.size();
int n = obstacleGrid[0].size();
vector<vector<int>> dp(m, vector<int> (n, 0));
// Initialize initial condition
bool flag = false;
for(int i = 0;i < m;i++) {
if(obstacleGrid[i][0] == 1) flag = true;
if(!flag) dp[i][0] = 1;
}
flag = false;
for(int j = 0;j < n;j++) {
if(obstacleGrid[0][j] == 1) flag = true;
if(!flag) dp[0][j] = 1;
}
for(int i = 1;i < m;i++)
for(int j = 1;j < n;j++) {
if(obstacleGrid[i][j] == 1) continue;
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
return dp[m - 1][n - 1];
}
};边栏推荐
- [hcie discussion] multicast igmp-a
- Several interview questions in TCP three grips and four swings
- Start blogging
- 你真的会用PostGIS中的buffer缓冲吗?
- KConfig
- 21 Chundong University blasting safety online peacetime operation 123 [standard answer]
- SAP 业务技术平台(BTP) Workflow(工作流)功能介绍
- VHDL编程实验练习题合集
- 63. 不同路径 II
- Explain bio, NiO, AIO in detail
猜你喜欢

Running of NCF dapr application instance

How to make maputnik, a vector tile matching artifact, support GeoServer

Video tracker error troubleshooting

leaflet中如何通过透明度控制layerGroup的显示隐藏

分公司能与员工签劳动合同么

M_ 8: Design a MySQL table for message queue to store message data

Do you have to read for PMP?

On the parameters of main function in C language
![Matlab [path planning] - UAV drug distribution route optimization](/img/b3/637fe426fcc960daf11bf640019589.png)
Matlab [path planning] - UAV drug distribution route optimization

【HCIE论述】组播IGMP-A
随机推荐
PLC can also make small games ----- CoDeSys can write small games of guessing numbers
【Matlab】矩阵变换与矩阵求值
[hcie discussion] multicast igmp-a
[matlab] basic operation
scala中的隐式转换和隐式参数讲解与实践
H5时代leaflet中还在用DivIcon?
C language standard IO, such as printf(), scanf(), etc
C # graphic tutorial (Fourth Edition) chapter7-7.6.1 virtual and override
[matlab] matrix transformation and matrix evaluation
Introduction to business rules service on SAP Business Technology Platform (BTP)
21 Chundong University blasting safety online peacetime operation 123 [standard answer]
【Matlab】三维曲线与三维曲面
How SAP ui5 uses manifest JSON file defines third-party library dependencies
PLC也能制作小游戏----Codesys编写猜数字小游戏
What are the PMP scores?
如何利用华为云容灾解决方案替代灾备一体机
Matlab【路径规划】—— 无人机药品配送路线最优化
2022 constructor - Equipment direction - General Foundation (constructor) operation certificate examination questions and simulation examination
Online examination questions for September examination of financial management
March 11, 2022 diary: Mr. Wang's spring, strange template mode