Multidequeue operation

is k is greater then n or less then n in this question??

Hey @shampblocks
See if k is greater than n, then the loop will stop after popping n elements, coz the while loop stops as and when queue becomes empty.
Also if k is less than, then the loop will stop after popping k elements, coz the while loop stops as and when m becomes 0.
So this code works for all values of k

so why is anser is order of n?? it shouldnot be depends on k??

Hey @shampblocks
The question is asking for the worst case complexity of the given code, right?
So basically in the worst case you can perform n pop operations(this would happen in the case where k >= n), so the ans is O(n).

we are calling multideque operation n times or we are just doint 1 time multideque operation on one queue?? i have a doubt in this…

@shampblocks
There’s one queue, and you are calling the dequeue operation multiple times on the same queue.

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.