Basic Calculator

Implement a basic calculator to evaluate a simple expression string containing integers, '+', '-', '(', and ')'. The string can contain spaces and may include parentheses. Return the result of the expression.

Input Format

s = arithmetic expression string with parentheses

Output Format

integer result of the expression

Constraints

Examples

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
Loading...
Basic Calculator - Stack DSA Problem