Basic Calculator II

Implement a basic calculator to evaluate a simple expression string containing non-negative integers and operators '+', '-', '*', and '/'. The string can contain spaces. The integer division should truncate toward zero.

Input Format

s = arithmetic expression string

Output Format

integer result of the expression

Constraints

Examples

Example 1:

Input:

s = "3+2*2"

Output:

7

Explanation:

Multiplication is evaluated before addition.

Example 2:

Input:

s = " 3/2 "

Output:

1

Explanation:

3/2 truncates toward zero to 1.

Loading...
Basic Calculator II - Stack DSA Problem