PUSH
POP
LIFO
[1,2,3]
β
PEEK
STACK HEROES
THE TOWER OF OPERATIONS
Master the art of Stack Operations
v1.0 - Educational Edition
THE TOWER OF OPERATIONS
Loading realms...
A Stack is a linear data structure that follows the LIFO (Last In, First Out) principle.
Think of it like a stack of plates - you can only add or remove plates from the top!
Add element to top
stack.push(value)
Remove top element
stack.pop()
View top element
stack.peek()
Count elements
stack.size()
| Operation | Time | Space |
|---|---|---|
| Push | O(1) | O(1) |
| Pop | O(1) | O(1) |
| Peek | O(1) | O(1) |
| Size | O(1) | O(1) |
Size: 0
Top: Empty
isEmpty: true
LIFO World
Learn the basics of stack operations.
// Stack Algorithm
function push(value) {
stack.add(value);
top = value;
}
Click on elements to interact with them.