algorythms
All Patterns
Pattern 20

Stack

Stack

LIFO (Last In First Out) data structure. Perfect for parsing strings, evaluating expressions, or matching pairs like parentheses.

Time

O(n)

Space

O(n)

Recognize it when

  • Matching pairs like nested parentheses
  • Evaluating postfix/RPN expressions
  • Tracking state that needs to be reversed or rewound
Progress0/3
0 solved0 attempted