Maximum element in every window of size K using deque

can’t understand q.front()<=i-k condition in while loop

hello @AjayRRJ
if we are at index i then we are only interested in elements having indexes
i-k+1 ,i-k+2,i-k+3,…i (k elements)

so it might happen that our deque is containing some indices in which we are not interested i.e who are having indices less than of equal to i-k.

so this q.front() <= i-k condition is checking the same and popping out all such elements from the deque.

Sir can you explain dry run of this code

please refer this -> https://www.youtube.com/watch?v=m-Dqu7csdJk