Maximum Element Deque

Hi, can u please explain why in this code he used ''while ((!q.empty()) and (q.front() <= i - k))" loop. I mean what is the significance of this particular loop.

hi @kartikey.rajput0071 u need to remove the elements from the front also as they are not the part of current window

Could you please explain it with an example ?

hi @kartikey.rajput0071 have you studied sliding window?

This is the first video on this particular concept

hi @kartikey.rajput0071 please read about sliding window before this from