Problem
s contains only ( and ). In one move you may insert one bracket anywhere in the string. Return the fewest moves that make s balanced.
Example 1
- Input
- s = "())"
- Output
- 1
- Why
- add a "(" at the front
Example 2
- Input
- s = "((("
- Output
- 3
Example 3
- Input
- s = ")("
- Output
- 2
Constraints
1 <= s.length <= 1000s[i] is ( or ).