Skip to content

Commit b63fbf8

Browse files
committed
update deque.pollLast
1 parent 88611d4 commit b63fbf8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

code/LeetCode/src/popular/SlidingWindowMaximum.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public int[] maxSlidingWindowWithDeque(int[] nums, int k) {
4545
}
4646
// remove smaller numbers in k range as they are useless
4747
while (!deque.isEmpty() && nums[deque.peekLast()] < nums[i]) {
48-
deque.poll();
48+
deque.pollLast();
4949
}
5050
// deque contains index... r contains content
5151
deque.offer(i);
@@ -59,7 +59,8 @@ public int[] maxSlidingWindowWithDeque(int[] nums, int k) {
5959
}
6060

6161
public static void main(String[] args) {
62-
int[] nums = {1,3,-1,-3,5,3,6,7};
62+
//int[] nums = {1,3,-1,-3,5,3,6,7};
63+
int[] nums = {1,3,1,2,0,5};
6364
int k = 3;
6465
SlidingWindowMaximum obj = new SlidingWindowMaximum();
6566
//int[] windowMax = obj.maxSlidingWindow(nums, k);

0 commit comments

Comments
 (0)