#224
Basic Calculator
candidate master · 1520 · lc hard +32 · verified · 46.6% accepted · 6,945 likes · top 31%
Description
Evaluate the arithmetic expression in string s and return its integer result.
Note: Using any built-in expression evaluator (such as eval()) is not permitted.
Example 1:
Input: s = "1 + 1"
Output: 2
Example 2:
Input: s = " 2-1 + 2 "
Output: 3
Example 3:
Input: s = "(1+(4+5+2)-3)+(6+8)"
Output: 23
Code
1
2
3