Approach Summary
Parse left to right. Push values onto stack; for * and / pop and compute immediately. Final answer is sum of stack.
How to Recognize This Pattern
- No parentheses, +−×÷ — handle precedence with stack
- Multiply/divide eagerly; add/subtract lazily to stack
Complexity Analysis
Time Complexity
O(n)
Space Complexity
O(n)
Tags
Math String Stack