package suanfa.queue;
import java.util.Stack;
public class TwoStackImpQueue {
Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack2 = new Stack<Integer>(); /** * 入队 * * @param node */ public void push(int node) { stack1.push(node); } /** * 出队 * * @return */ public int pop() { if (stack2.isEmpty()) { while (!stack1.isEmpty()) { stack2.push(stack1.pop()); } } return stack2.pop(); }
}