How can one reverse a Queue in O(1) space complexity?
The answer here: Can I reverse a queue without using stack? says that it is possible with a stack. But I don’t understand how this process is O(1) space complexity:
Step 1: Enqueue then Dequeue every element of a Queue into a Stack
Step 2: Enqueue the Front value of the Stack into the Queue then Pop off every element of the Stack
Wouldn’t the Stack use O(n) space complexity for every element in the Queue?