Basic Calculator
Implement a basic calculator to evaluate a simple expression string.
The expression string may contain open(
and closing parentheses)
, the plus+
or minus sign-
,non-negativeintegers and empty spaces.
Example 1:
Example 2:
Example 3:
分析
带括号,所以每次相乘带sign,遇到括号把+1/-1sign压入,再压入前面result。遇到)就弹出站
Last updated