Netflix interview question

How to implement a queue using stack? ( not this question, but this type of questions and the question many be more difficult than this.)

Interview Answer

Anonymous

3 Aug 2022

Push() values onto one stack. Pop() all values and reverse the order by pushing onto another stack. Now you have a stack that can pop() the very first value, followed by the rest of the values in order.

2