Flashcards
Implement Stack using Queues
Flashcards do conjunto (1)
- 1push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- Return whether the stack is empty.class MyStack {
Queue q = null;
/** Initialize your data structure here. */
public MyStack() {
q = new LinkedList<>();
}
/** Push element x onto stack. */
public void push(int x) {
q.add(x);
for( int i = 1; i
Informações
- Descrição
- FlashCards sobre Implement Stack using Queues, criado por Suhas S em 13-05-2018.
- Criado por
- Suhas S
- Visualizações
- 0
- Avaliação