Home
Log in
DescriptionSubmissionsSolution
DescriptionSubmissionsSolution
Loading...

Log in to run or submit

tokens =

Codey

Practise coding problems, test your solutions and track your progress.

Explore

  • Problems
  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

© 2026 Codey. Personal learning project.

Solution
Updated: 2026-02-23

Idea

Reverse Polish Notation is evaluated using a stack.

Approach

Scan tokens:

  • If number, push it.
  • If operator, pop two operands a, b, compute a op b, and push the result. Division truncates toward zero.

Why it works

Every operator applies to the most recent two values that haven’t yet been combined.

Code
Loading...
Complexity
Time: O(n)
Space: O(n)
Solution
Updated: 2026-02-23

Idea

Reverse Polish Notation is evaluated using a stack.

Approach

Scan tokens:

  • If number, push it.
  • If operator, pop two operands a, b, compute a op b, and push the result. Division truncates toward zero.

Why it works

Every operator applies to the most recent two values that haven’t yet been combined.

Code
Loading...
Complexity
Time: O(n)
Space: O(n)