标签:输入 如何 一个队列 style ack push public ret scribe
1 import java.util.Stack; 2 public class Solution { 3 Stack<Integer> stack1 = new Stack<Integer>(); 4 Stack<Integer> stack2 = new Stack<Integer>(); 5 6 public void push(int node) { 7 stack1.push(node); 8 } 9 10 public int pop() { 11 if(stack1.empty()&&stack2.empty()){ 12 System.out.println("The queue is empty!"); 13 } 14 if(stack2.empty()){ 15 while(!stack1.empty()){ 16 stack2.push(stack1.pop()); 17 } 18 } 19 return stack2.pop(); 20 } 21 }
标签:输入 如何 一个队列 style ack push public ret scribe
原文地址:https://www.cnblogs.com/Octopus-22/p/9419677.html