import java.util.Stack; //P232leetcode public class MyQueue { Stackstack1; Stackstack2; public MyQueue(){ stack1=new Stack<>(); stack2=new Stack<>(); } public void push(int x){ while(!stack1.isEmpty()){ stack2.push(stack1.pop()); } stack1.push(x); while(!stack2.isEmpty()){ stack1.push(stack2.pop()); } } public int pop(){ return stack1.pop(); } public int peek(){ return stack1.peek(); } public boolean empty(){ return stack1.isEmpty(); } }