You are given an array of strings tokens representing an arithmetic expression written in Postfix Notation (also known as Reverse Polish Notation).
Your task is to evaluate the expression and return its integer result.
Rules:
• The valid operators are: +, -, *, /
• Each operand is either an integer or another valid postfix expression.
• Division between two integers truncates toward zero (e.g., 8 / -3 = -2).
• No division by zero will occur.
• The input always represents a valid arithmetic expression.
• The final result and all intermediate results fit in a 32-bit signed integer.
Input: tokens = ["5", "3", "+", "2", "*"]
Output: 16
Input: tokens = ["8", "4", "/", "6", "+"]
Output: 8
Input: tokens = ["12", "3", "-", "2", "5", "*", "+"]
Output: 19
Accepted:
Submission: