cheetcode

23. Evaluate Reverse Polish NotationMedium

Evaluate an arithmetic expression written in Reverse Polish Notation.

You are given an array of strings tokens that represents an arithmetic expression in Reverse Polish Notation.

Return the value of the expression. Division between two integers should truncate toward zero.

Examples

Input: tokens = ["2","1","+","3","*"]
Output: 9
Input: tokens = ["4","13","5","/","+"]
Output: 6

Constraints

  • 1 <= tokens.length <= 10,000
  • tokens[i] is an integer or one of +, -, *, /.
  • The expression is always valid.