Deque maintains decreasing values (by index).
Invariant: If and , can never be max while exists. Remove .
Front: Current window's max index.
Example: ,
- : , pop, push:
- : push: . Max=
- : push: . Max=
- : all, pop all: . Max=
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Understanding the deque invariant.
Deque maintains decreasing values (by index).
Invariant: If and , can never be max while exists. Remove .
Front: Current window's max index.
Example: ,