Skip to content

Commit aa1b47e

Browse files
authored
Update 2831-find-the-longest-equal-subarray.js
1 parent cbea16d commit aa1b47e

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

2831-find-the-longest-equal-subarray.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ const longestEqualSubarray = function(nums, k) {
3434
cnt[e]++
3535
res = Math.max(res, cnt[e])
3636

37-
while(j - i + 1 - res > k) {
37+
if(j - i + 1 - res > k) {
3838
const pre = nums[i]
3939
if(cnt[pre] == null) cnt[pre] = 0
4040
cnt[pre]--
4141
i++
42-
res = Math.max(res, cnt[nums[i]])
4342
}
4443
}
4544

0 commit comments

Comments
 (0)