Minimum Insertions to Balance a Parentheses String

Hard

📝 Description

Calculate minimum insertions needed to balance parentheses

Input Format

String s containing "(" and ")"

Output Format

Minimum insertions

Constraints

1 ≤ s.length ≤ 10^5

🔍 Sample Input

"(()))"
            

✅ Sample Output

1
            

Code Editor

Please login to run and submit code.

Shortcuts: Ctrl+Enter to submit, Ctrl+Shift+R to run