diff --git a/problems/0376.摆动序列.md b/problems/0376.摆动序列.md index 7da39526..5587a8c7 100644 --- a/problems/0376.摆动序列.md +++ b/problems/0376.摆动序列.md @@ -239,7 +239,7 @@ var wiggleMaxLength = function(nums) { let result = 1 let preDiff = 0 let curDiff = 0 - for(let i = 0; i <= nums.length; i++) { + for(let i = 0; i < nums.length - 1; i++) { curDiff = nums[i + 1] - nums[i] if((curDiff > 0 && preDiff <= 0) || (curDiff < 0 && preDiff >= 0)) { result++