I think in parenthese problem, use stack is the easiest one, just follow the algorithm, we have 3 situations:
1. ‘(’: push to stack
2. ‘)’ && st.top() == ‘(’: pop the ‘)’ and push 1
3. ‘)’ && st.top() != ‘(’: sum all the number within brackets, then mult 2.
And finally, sum all the number then get the result.
Error:
N/A