The operations that needed to be performed are (You can perform only push and pop):
A. Push(pop()), push(6), push(pop())
B. Push(pop()), push(6)
C. Push(pop()), push(pop()), push(6)
D. Push(6)
Answer:A
The operations that needed to be performed are (You can perform only push and pop):
A. Push(pop()), push(6), push(pop()) B. Push(pop()), push(6) C. Push(pop()), push(pop()), push(6) D. Push(6)
Explanation: 2 3 4 5 top is obtained by executing push(pop()) on all elements on the current stack to the next stack. You’ll get 6 5 4 3 2 top if you push(6) and then push(pop()). You’ve simply used push and pop to conduct an enQueue process.