Problem Statement | |||||||||||||
We have an arithmetic expression made up of positive integers, the + and - operators and parentheses. All the parentheses, however, have been erased by the cleaning staff and we want to calculate the minimum value the original expression may have had. You will be given a String e containing the expression without the parentheses. Return the minimum value the original expression could have had before the parentheses were erased. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | All operations in the original expression were addition and subtraction; there were no parentheses placed between two consecutive digits. | ||||||||||||
Constraints | |||||||||||||
- | e will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | Each character of e will be a digit ('0'-'9'), a plus sign ('+') or a minus sign ('-'). | ||||||||||||
- | The first and last characters of e will be digits. | ||||||||||||
- | No two operators (characters '+' and '-') will appear consecutively in e. | ||||||||||||
- | There will not be a sequence of more than 5 consecutive digits in e. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
|