Given a string s representing a mathematical expression containing non-negative integers and the operators +, -, *, and /, evaluate the expression and return its result.
Integer division must truncate toward zero. You may assume the expression is always valid, and all intermediate results fall within the
Note: Using any built-in function that directly evaluates strings as mathematical expressions (e.g.,
eval()) is not allowed.
Constraints:
s.length
s consists of non-negative integers and operators ('+', '-', '*', '/') separated by some number of spaces
s represents a valid expression
All integers in s are in the range
The answer is guaranteed to fit within a
Given a string s representing a mathematical expression containing non-negative integers and the operators +, -, *, and /, evaluate the expression and return its result.
Integer division must truncate toward zero. You may assume the expression is always valid, and all intermediate results fall within the
Note: Using any built-in function that directly evaluates strings as mathematical expressions (e.g.,
eval()) is not allowed.
Constraints:
s.length
s consists of non-negative integers and operators ('+', '-', '*', '/') separated by some number of spaces
s represents a valid expression
All integers in s are in the range
The answer is guaranteed to fit within a