Skip to content

Commit 7081a0f

Browse files
Merge pull request #773 from Jerry-306/patch-11
更新 0053 最大子序和 JavaScript 解法
2 parents 9fa333e + 270757a commit 7081a0f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

problems/0053.最大子序和(动态规划).md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ JavaScript:
173173
```javascript
174174
const maxSubArray = nums => {
175175
// 数组长度,dp初始化
176-
const [len, dp] = [nums.length, [nums[0]]];
176+
const len = nums.length;
177+
let dp = new Array(len).fill(0);
177178
// 最大值初始化为dp[0]
178179
let max = dp[0];
179180
for (let i = 1; i < len; i++) {

0 commit comments

Comments
 (0)