Grokking Data Structures & Algorithms for Coding Interviews
Vote

0% completed

Stretch Problem: Evaluate Reverse Polish Notation (medium)

This problem is optional. The problems above cover what the chapter teaches. This one is here for readers who want a harder stack question, and nothing later in the course depends on it.

Problem Statement

You are given an array of strings tokens that holds an arithmetic expression in Reverse Polish Notation, where each operator comes after the two values it applies to. The valid operators are +, -, * and /.

Evaluate the expression and return the result as an integer.

Notes:

  • Division between two integers truncates toward zero, so -7 / 2 is -3.

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content