Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use a stack to keep opening brackets. If you face single closing ')' add 1 to the answer and consider it as '))'.
If you have '))' with empty stack, add 1 to the answer, If after finishing you have x opening remaining in the stack, add 2x to the answer.