Implement Stack using Queues
Signals to notice
Brute force first
No simpler alternative — you must simulate with the available structure. That direct path helps you understand the question, but it tends to treat every possibility as brand new instead of learning from earlier steps.
The key insight
Two queues: on push, enqueue to q2, then move all elements from q1 to q2, then swap q1 and q2. This makes push but pop/top. Or make pop costly instead. The goal is not to be clever for its own sake, but to remember the one relationship that keeps the solution grounded as you move forward.
What must stay true
After each push, q1 always has elements in stack order (newest first). The re-enqueueing step reverses the order so that the front of q1 is the top of the stack. If that remains true after every update, the rest of the reasoning has a stable place to stand.
Easy way to go wrong
Making both push and pop costly — choose one. Costly push means every push rearranges; costly pop means every pop rearranges. Pick based on which operation is more frequent. When the code becomes mechanical before the idea is clear, small edge cases start breaking the whole story.