This commit is contained in:
krahets
2023-09-02 23:03:42 +08:00
parent 799698e67c
commit 503ca797b8
12 changed files with 314 additions and 91 deletions

View File

@@ -659,10 +659,7 @@ $$
return 1;
}
// 初始化 dp 表,用于存储子问题的解
const dp = Array.from(
{ length: n + 1 },
() => new Array(3)
);
const dp = Array.from({ length: n + 1 }, () => new Array(3));
// 初始状态:预设最小子问题的解
dp[1][1] = 1;
dp[1][2] = 0;