Stacks & Queues

Your answer
Answer & solution
Answer: B: 34521 (no official key was published)
Step through it (4 options)
Push 1,2,3 and pop 3; push 4 and pop 4; push 5 and pop 5; then pop 2 and 1. This constructs 34521. For 34512, after producing 345 the stack has 2 above 1, so 1 cannot come next. For 15234, after popping 1 then pushing through 5, the next available value is 4, not 2. For 54312, after popping 5,4,3, value 2 still blocks 1. Thus only B is feasible.