Basic Calculator

hard
Given a string s representing an expression, implement a basic calculator to evaluate it.

Input Format

Input is managed for you

Output Format

Output is managed for you

Constraints

1. 1 <= s.length <= 3 * 10^5
2. s consists of digits, '+', '-', '(', ')', and ' '.
3. s represents a valid expression.
4. result of the expression always lies in range of -2^31 to 2^31

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
(1+(4+5+2)-3)+(6+8)
Output
23
Previous
Trapping Rain Water
Next
Number Of Valid Subarrays

Related Questions