Problem 47838. Count the ways pairs of parentheses can be matched correctly

Several problems in Cody deal with the practical problem of checking whether parentheses are correctly matched (e.g., 80, 465, 1303, 2653). In this problem you are asked to count the ways a given number of pairs of parentheses can be matched correctly in an expression. For example, three pairs can be matched in five ways:
()()(), (())(), (()()), ((())), ()(())
Write a function that takes the number of pairs and determines the number of ways the parentheses can be matched correctly.

Solution Stats

57.14% Correct | 42.86% Incorrect
Last Solution submitted on Jun 08, 2025

Solution Comments

Show comments

Problem Recent Solvers7

Suggested Problems

More from this Author301

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!