In the question, we have a for loop inside which we dequeue n times. Does that not mean O(n^2)?
The dequeue operation takes n
primitive operations to dequeue an element from the queue. The loop runs n
times, which makes O(n^2).
Anum Hassan | Developer Advocate
educative.io
1 Like