solve(s) — evaluate an arithmetic expression made of non-negative integers, +, -,*, / and spaces. There are no parentheses. Integer division truncates toward zero.
Do not use eval — and the user-typed expression is exactly the kind of string you must never
evaluate as code.
Use a stack of terms. Remember the operator that came before the current number:+ pushes num, - pushes -num, * and / combine num with the value on top of the
stack (this gives * and / their higher precedence). The answer is the sum of the stack.
Examples
solve("3+2*2") → 7
solve(" 3/2 ") → 1
solve(" 3+5 / 2 ") → 5
solve("1-5/2") → -1 // 5/2 = 2, then 1 - 2Sample tests