Balanced Parentheses Count
Return the number of different strings made of pairs opening and pairs closing parentheses in which every prefix has at least as many opening as closing ones, and the totals are equal (balanced strings, like (()) and ()()).
Example 1
pairs 3
returns 5
((())), (()()), (())(), ()(()), ()()(): 5.
Constraints
0 <= pairs <= 10
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More Math problems
- Convert to Base Minus TwoMedium
- Count Numbers With Unique DigitsMedium
- Count PrimesMedium
- Day of the WeekMedium
- Fast PowerMedium
- Friday the 13th CountMedium
- Last Digit of a PowerMedium
- Last Person StandingMedium