Description
Given a string s which represents an expression, evaluate this expression and return its value. The integer division should truncate toward zero. You may assume the expression is always valid. The expression contains only non-negative integers, '+', '-', '*', '/' operators and empty spaces.
Examples
Input:
s = "3+2*2"Output:
7Explanation:
Multiplication first: 3 + 4 = 7.
Input:
s = " 3/2 "Output:
1Explanation:
3 / 2 = 1 (integer division).
Input:
s = " 3+5 / 2 "Output:
5Explanation:
5 / 2 = 2, then 3 + 2 = 5.
Constraints
- •
1 ≤ s.length ≤ 3 × 10⁵ - •
s consists of integers and operators '+', '-', '*', '/'.