Palo Alto Networks·Software Engineer·Technical Phone Screen
- Given a string representing a basic arithmetic expression with non-negative integers and +, -, *, / operators separated by spaces, evaluate it and return the result. Integer division should truncate toward zero. You cannot use any built-in expression evaluators like eval().
- Follow-up: how would you extend your solution to handle parentheses, for example an expression like '2 * (3 + 4) - (1 + 2)'? Walk through how you'd adapt the stack-based approach.
“Stack-based solution, pretty classic.”