标签:
Stack<Integer> stack=new Stack<Integer>();
public void push(int x) {
stack.push(x);
}
// Removes the element from in front of queue.
public void pop() {
stack.remove(0);
}
// Get the front element.
public int peek() {
return stack.get(0);
}
// Return whether the queue is empty.
public boolean empty() {
return stack.isEmpty();
}
Java for LeetCode 232 Implement Queue using Stacks
标签:
原文地址:http://www.cnblogs.com/tonyluis/p/4831924.html