Google (Phone Screen) - Evaluate Expression with API
Anonymous User
1165

Given an arithmetic expression with (e.g., (3 + 5 - (2 + 4) / 2), write a recursive program to evaluate the expression. You are given an API parse(string) that will take in a string and return a parsed version of that string for you. The parse(string) API returns the left and right operands as well as the operator.

For example, parse("3 + 5") would return ["3", "+", "5"], parse("1") would return ["1"], and parse("(1 + 1) / 2" would return ["(1 + 1)", "/", "2"]

I failed the interview. How can I solve this problem? Note that it's different from Basic Calculator because you need to use the provided parse API.

Comments (4)