Queue from Two Stacks

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • easy
  • Pro

Build a first-in, first-out queue using only two stacks. Explain how adding and removing work, and why each operation costs constant time on average.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →