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:7
Explanation:

Multiplication first: 3 + 4 = 7.

Input:s = " 3/2 "
Output:1
Explanation:

3 / 2 = 1 (integer division).

Input:s = " 3+5 / 2 "
Output:5
Explanation:

5 / 2 = 2, then 3 + 2 = 5.

Constraints

  • 1 ≤ s.length ≤ 3 × 10⁵
  • s consists of integers and operators '+', '-', '*', '/'.

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!