Condition in 2nd iteration

Code is:
for(;i<n;i++)
{
while((!q.empty() && (q.front() <= i-k))…
}

doubt: What is the logic behind writing q.front() <= i-k, I mean to ask that q.front() will be a value and we are comparing value to index/position…why???

hello @acharyadhwanan29
In deque we are storing index only.

in the condition q.front() <= i-k
we are popping out all indices from deque whose value <=i-k .

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.