Following up on this question: Implement Stack using Two Queues
I'm looking to implement Version A (efficient push) of the answer however I also need to be considerate of the queue size i.e. I cannot 'enqueue forever' but at a certain point the queue will run out of space.
I need to make sure all push operations are done with constant time complexity.
How would I go on to implement this? Copying the queue once its full will obviously result in a complexity of O(n).
I could create a new empty queue and start pushing there, however it needs to represent a stack and at a certain point at pop operations, it will reach the end of the new queue and won't know the rest of the items are in the old queue.