Update 0239.滑动窗口最大值.md

This commit is contained in:
SkyLazy 2021-07-22 17:19:15 +08:00 committed by GitHub
parent 53134a023a
commit 59755d57f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -273,8 +273,8 @@ class Solution {
int[] res = new int[n - k + 1]; int[] res = new int[n - k + 1];
int idx = 0; int idx = 0;
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
// 根据题意i为nums下标是要在[i - k + 1, k] 中选到最大值,只需要保证两点 // 根据题意i为nums下标是要在[i - k + 1, i] 中选到最大值,只需要保证两点
// 1.队列头结点需要在[i - k + 1, k]范围内,不符合则要弹出 // 1.队列头结点需要在[i - k + 1, i]范围内,不符合则要弹出
while(!deque.isEmpty() && deque.peek() < i - k + 1){ while(!deque.isEmpty() && deque.peek() < i - k + 1){
deque.poll(); deque.poll();
} }