Loading...
Loading...
Loading...
Evaluate an expression with non-negative integers, + and -, round brackets, and spaces. A minus sign may appear before a bracket or at the start, as in -(2+3) or (-2). Print the value.
Example 1
Input
1 + 1
Output
2
The value is 2.
Example 2
Input
(1+(4+5+2)-3)+(6+8)
Output
23
Try the problem first. Open one hint at a time.
Keep a running result and the current sign.
On ( push the result and the sign, then restart. On ) combine the inner result with the saved sign and result.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor