FunctionRacerProblemsRace

Balanced Parentheses Count

MediumMathPython, JavaScript, TypeScript, Java, C++

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

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems