You are given a string s representing a valid mathematical expression. The expression may contain non-negative integers, the operators '+', '-', '*', '/', parentheses '(', ')', and spaces.
Evaluate the expression and return its result as an integer.
Note that integer division should truncate toward zero. You are not allowed to use any built-in function that evaluates strings as mathematical expressions (such as eval()).
Constraints:
1 <= s.length <= 10^4s consists of digits, operators '+', '-', '*', '/', parentheses '(', ')', and spaces.Return the integer result of evaluating the expression.
Need help or want more practice?