Company: ibm_12oct
Difficulty: medium
Evaluate Prefix Expression Problem Description A prefix expression is one which has the operator proceeding the operands. Write a function evalPrefix() to evaluate such prefix notations. You will be given an array of strings ( prefixExp ) as a function argument. Valid operators are + , - , * , and / . Each operand may be an integer or another expression. Examples Example 1: Input: prefixExp = ["/", "5", "3"] Output: 1 Explanation: This evaluates to 5 / 3, which results in 1 (assuming integer division). Example 2: Input: prefixExp = ["+", "4", "*", "10", "-", "9", "3"] Output: 64 Explanation: This expression can be broken down as follows: - "9" "3" evaluates to 9 - 3 = 6. * "10" "6" (where 6 is the result of the previous step) evaluates to 10 * 6 = 60. + "4" "60" (where 60 is the result of the previous step) evaluates to 4 + 60 = 64.