Grokking the Engineering Manager Coding Interview
Ask Author
Back to course home

0% completed

Solution: Evaluate Reverse Polish Notation
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Problem Statement

Given an array of strings tokens that represents an arithmetic expression in Reverse Polish Notation (RPN), evaluate the expression and return the resulting integer value.

  • The valid operators are '+', '-', '*', and '/'.
  • Each operand can be an integer or another expression.
  • Division between two integers should truncate towards zero.
  • No division by zero will occur.
  • The input is a valid RPN expression.
  • All results fit within a 32-bit integer.

Examples

Example 1

  • Input: tokens = ["2", "11", "5", "/", "+"]
  • Output: 4

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible