Create a simple calculator that can evaluate arithmetic expressions given as strings.
The expressions will only include non-negative integers and the operators +
, -
, *
, /
, along with optional spaces. Division should truncate results towards zero.
You can assume the input expression is always valid and no built-in evaluation functions should be used.
Example 1: Input: "4+3*5" Output: 19
Example 2: Input: " 8 / 4 " Output: 2
Example 3: Input: " 10 + 6 / 3 " Output: 12