← Stack

Pattern Recognition Drill

#19 — Evaluate postfix expression

Easy Stacks & Queues

The Problem

Evaluate a postfix (reverse Polish notation) expression.

What approach would you use?

Think about it before scrolling down.

Key Signals

Stack

Push numbers. On operator, pop two, apply, push result. Final stack element is the answer. O(n).

Common Trap

Watch operand order for non-commutative ops: second_popped OP first_popped (e.g., subtraction).

← #18 #20 →