您的位置:首页 > 产品设计 > UI/UE

Java for LeetCode 232 Implement Queue using Stacks

2015-09-23 12:55 459 查看
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();

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: