Basic Calculator II (LC #227) evaluates expressions with +, -, *, /. Use a stack for numbers. Track the previous operator. When you see a new operator or reach the end, apply the previous operator. For + and -, push the number (negated for -). For * and /, pop, compute with current number, push result. Sum the stack at the end. This runs in time and space. Meta often simplifies to only + and *. The full Basic Calculator (LC #224) with parentheses uses recursion.
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
$ curl repovive.com/roadmaps/meta-interview-prep/stacks-queues/basic-calculator-ii
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████████████████████████████████████████████████████████████████████████████████