Basic Calculator II
Last updated
Was this helpful?
Last updated
Was this helpful?
Given a string s
which represents an expression, evaluate this expression and return its value.
The integer division should truncate toward zero.
(The difference between this and Basic Calculator I is that in here we have all the operands and no paranthese, while in Basic Calculator I we only had '+' and '-' and parantheses.)
Multiplication and division need to be handled before addition and subtraction
Once again here we are saving the previous sign like in Basic Calculator I
Time: O(n)
Space: O(n)