Back to problems

Evaluate Reverse Polish Notation

Algorithm · Stripe · Medium

You are given an array of tokens describing an expression in Reverse Polish Notation; return the expression's evaluated result. The permitted operators are +, -, , and /. A token can be an integer value or a nested subexpression. Division of integers must discard the fractional part by truncating toward zero. For instance, ["3", "4", "+", "2", ""] evaluates to 14 because (3 + 4) * 2 = 14; ["7", "3", "/", "5", "+"] evaluates to 7 because 7 / 3 truncates to 2, and 2 + 5 = 7.…

Checking your access…