`{"id":"115f1b07-4ecc-4a1c-9943-8000cf17da3d","name":"Count Brackets","description":"1. You are given a number n, representing the number of opening brackets ( and closing brackets )\r\n2. You are required to find the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets\r\ne.g.\r\nfor 1, answer is 1 -> ()\r\nfor 2, answer is 2 -> ()(), (())\r\nfor 3, asnwer is 5 -> ()()(), () (()), (())(), (()()), ((()))","inputFormat":"A number n","outputFormat":"A number representing the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets","constraints":"0 &lt;= n &lt;= 15","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4","sampleOutput":"14","questionVideo":"https://www.youtube.com/embed/n-8R95-5MXw?end=549","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"dccad2d6-0b63-4737-acd1-4cc9160a6cef","name":"Count Brackets","slug":"count-brackets","type":1}],"next":{"id":"54acc5fb-90df-43cb-95d2-f96b87af5345","name":"Maximum Sum Increasing Subsequence","type":1,"slug":"maximum-sum-increasing-subsequence"},"prev":{"id":"a7c4671c-eeb5-4df7-8e71-12d73cfbbf83","name":"Count Of Valleys And Mountains","type":1,"slug":"count-of-valleys-and-mountains"}}}`

Count Brackets

1. You are given a number n, representing the number of opening brackets ( and closing brackets ) 2. You are required to find the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets e.g. for 1, answer is 1 -> () for 2, answer is 2 -> ()(), (()) for 3, asnwer is 5 -> ()()(), () (()), (())(), (()()), ((()))

`{"id":"115f1b07-4ecc-4a1c-9943-8000cf17da3d","name":"Count Brackets","description":"1. You are given a number n, representing the number of opening brackets ( and closing brackets )\r\n2. You are required to find the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets\r\ne.g.\r\nfor 1, answer is 1 -> ()\r\nfor 2, answer is 2 -> ()(), (())\r\nfor 3, asnwer is 5 -> ()()(), () (()), (())(), (()()), ((()))","inputFormat":"A number n","outputFormat":"A number representing the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets","constraints":"0 &lt;= n &lt;= 15","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main{\r\n\r\npublic static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"4","sampleOutput":"14","questionVideo":"https://www.youtube.com/embed/n-8R95-5MXw?end=549","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"dccad2d6-0b63-4737-acd1-4cc9160a6cef","name":"Count Brackets","slug":"count-brackets","type":1}],"next":{"id":"54acc5fb-90df-43cb-95d2-f96b87af5345","name":"Maximum Sum Increasing Subsequence","type":1,"slug":"maximum-sum-increasing-subsequence"},"prev":{"id":"a7c4671c-eeb5-4df7-8e71-12d73cfbbf83","name":"Count Of Valleys And Mountains","type":1,"slug":"count-of-valleys-and-mountains"}}}`

Editor

Count Brackets

easy

1. You are given a number n, representing the number of opening brackets ( and closing brackets ) 2. You are required to find the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets e.g. for 1, answer is 1 -> () for 2, answer is 2 -> ()(), (()) for 3, asnwer is 5 -> ()()(), () (()), (())(), (()()), ((()))

0 <= n <= 15

Format

A number n

Output

A number representing the number of ways in which you can arrange the brackets if the closing brackets should never exceed opening brackets

Example

Sample Input

`.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}4`

Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}14`

Question Video

Discussions

Show Discussion

Related Resources