From fe99dff9d328277913ab36703472e2f8a20b8fb6 Mon Sep 17 00:00:00 2001 From: John Li Date: Thu, 23 Nov 2023 19:01:59 +0800 Subject: [PATCH] =?UTF-8?q?Updata=20494=20=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "problems/0494.\347\233\256\346\240\207\345\222\214.md" | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git "a/problems/0494.\347\233\256\346\240\207\345\222\214.md" "b/problems/0494.\347\233\256\346\240\207\345\222\214.md" index a90a38f71d..1a4dda2b0a 100644 --- "a/problems/0494.\347\233\256\346\240\207\345\222\214.md" +++ "b/problems/0494.\347\233\256\346\240\207\345\222\214.md" @@ -325,10 +325,8 @@ class Solution { // 初始化最上行(dp[0][j]),当nums[0] == j时(注意nums[0]和j都一定是大于等于零的,因此不需要判断等于-j时的情况),有唯一一种取法可取到j,dp[0][j]此时等于1 // 其他情况dp[0][j] = 0 // java整数数组默认初始值为0 - for(int j = 0; j <= left; j++) { - if(nums[0] == j) { - dp[0][j] = 1; - } + if (nums[0] <= left) { + dp[0][nums[0]] = 1; } // 初始化最左列(dp[i][0])