educative.io

Error in the solution #3

“This solution is the best of the three solutions in this lesson, as the transfer of elements between stacks takes place only if tempStack is empty. Therefore, the amortized complexity of the dequeue operation becomes O(1) while the time complexity for the enqueue operation is O(n).

I think this is inverted: dequeue takes O(n) and enqueue takes O(1)

Hi Alejandro,
The lesson has been updated. Thank you for your feedback!
Alina Fatima | Developer Advocate

1 Like