Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[pull] master from youngyangyang04:master #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
pull merged 6 commits into AlgorithmAndLeetCode:master from youngyangyang04:master
Jun 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update 0063.不同路径II.md
  • Loading branch information
jianghongcheng authored Jun 12, 2023
commit 5527410f890ecfccdb017ce5aa5fc902328ab922
32 changes: 32 additions & 0 deletions problems/0063.不同路径II.md
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,39 @@ class Solution:

```

动态规划(版本五)

```python
class Solution:
def uniquePathsWithObstacles(self, obstacleGrid):
if obstacleGrid[0][0] == 1:
return 0

m, n = len(obstacleGrid), len(obstacleGrid[0])

dp = [0] * n # 创建一个一维列表用于存储路径数

# 初始化第一行的路径数
for j in range(n):
if obstacleGrid[0][j] == 1:
break
dp[j] = 1

# 计算其他行的路径数
for i in range(1, m):
if obstacleGrid[i][0] == 1:
dp[0] = 0
for j in range(1, n):
if obstacleGrid[i][j] == 1:
dp[j] = 0
continue

dp[j] += dp[j - 1]

return dp[-1] # 返回最后一个元素,即终点的路径数


```
### Go

```go
Expand Down

AltStyle によって変換されたページ (->オリジナル) /