Answer is coming right but a general doubt

why i have to run a loop to pop back first n elements from line 19 to 22 and only then my answer coming right and when input integer like this in queue-
for(int i=0;i<n;i++){
cin>>x;
q.push_back(x);
}
then the first 5 elements are stored as 0 .
you can try and test.

@aryaman.kumar26 sorry cant understand what you are trying to say.
send me the corrected code and the wrong code both

check my code again from line 19 to 22 i have used a loop to pop out first 5 elements. Now run the code without that loop and check the answer then.

@aryaman.kumar26 corrected it one small mistake


(before by chance it was coming right due to weak cases)

what was the mistake?

@aryaman.kumar26 commented it deque q(n) (n) this was not req

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.