Stack & Queue

LIFO stack operations and bracket matching

Stack & Queue: Stack

Stack
Pick a stack operation to animate the LIFO behavior.

Stack Patterns

Push adds a new item to the top, while Pop removes from the same side of the structure.

Peek inspects the current top without mutating the stack.

Balanced Parentheses uses the stack to match every closing bracket against the latest open bracket.

Complexity

Push
Time:O(1)
Space:O(1)
Pop
Time:O(1)
Space:O(1)
Peek
Time:O(1)
Space:O(1)
Balanced Parentheses
Time:O(n)
Space:O(n)