Company: ibm_12oct
Difficulty: medium
Evaluate Prefix Expression Problem Description In a prefix expression every operator is written before its two operands. For example, the ordinary expression (9 - 3) is written as - 9 3 , and 4 + 10 * (9 - 3) is written as + 4 * 10 - 9 3 . An operand is either an integer or another complete prefix expression. You are given the tokens of a valid prefix expression as an array of strings prefixExp . Each token is one of the operators + , - , * , / , or an integer. Evaluate the expression and return its value. For an operator op followed by the operands X and then Y , the value is X op Y : the operand that comes first is the left-hand side. For example, - 9 3 is 9 - 3 = 6 and / 5 3 is 5 / 3 . Division is integer division that truncates toward zero : 5 / 3 = 1 , -7 / 2 = -3 , 7 / -2 = -3 and 4 / 9 = 0 . Function Description Complete the function evalPrefix in the editor with the following parameter: string prefixExp[n] : the tokens of the prefix expression, in order Returns: int : the value