Fichas
Implement Stack using Queues
Fichas del 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
Información
- Descripción
- Fichas sobre Implement Stack using Queues, creado por Suhas S el 13/05/2018.
- Creado por
- Suhas S
- Visitas
- 0
- Valoración