From a4e22fb2d61411dfdccd27995079bd92f3396e96 Mon Sep 17 00:00:00 2001 From: ShuBo6 <814183583@qq.com> Date: Mon, 30 Jan 2023 22:29:45 +0800 Subject: [PATCH] =?UTF-8?q?bug&&typo:=200063=E4=B8=8D=E5=90=8C=E8=B7=AF?= =?UTF-8?q?=E5=BE=84II,0343=E6=95=B4=E6=95=B0=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.bug: 0063不同路径II go版本代码 2. typo:0343整数拆分 --- problems/0063.不同路径II.md | 6 ++++-- problems/0343.整数拆分.md | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/problems/0063.不同路径II.md b/problems/0063.不同路径II.md index 9aa36956..96873cfd 100644 --- a/problems/0063.不同路径II.md +++ b/problems/0063.不同路径II.md @@ -335,6 +335,10 @@ class Solution: ```go func uniquePathsWithObstacles(obstacleGrid [][]int) int { m, n := len(obstacleGrid), len(obstacleGrid[0]) + //如果在起点或终点出现了障碍,直接返回0 + if obstacleGrid[m-1][n-1] == 1 || obstacleGrid[0][0] == 1 { + return 0 + } // 定义一个dp数组 dp := make([][]int, m) for i, _ := range dp { @@ -359,8 +363,6 @@ func uniquePathsWithObstacles(obstacleGrid [][]int) int { } return dp[m-1][n-1] } - - ``` ### Javascript diff --git a/problems/0343.整数拆分.md b/problems/0343.整数拆分.md index 25a63154..78c76cbd 100644 --- a/problems/0343.整数拆分.md +++ b/problems/0343.整数拆分.md @@ -88,7 +88,7 @@ dp[i] 是依靠 dp[i - j]的状态,所以遍历i一定是从前向后遍历, 所以遍历顺序为: ```CPP for (int i = 3; i <= n ; i++) { - for (int j = 1; j <= i / 2; j++) { + for (int j = 1; j < i - 1; j++) { dp[i] = max(dp[i], max((i - j) * j, dp[i - j] * j)); } }