Please enter your email address or userHandle.
Given a number N. The task is to find the nth Catalan number.
The first few Catalan numbers for n = 0, 1, 2, 3, … are 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, …
The first line of input contains a single integer T which denotes the number of test cases. The first line of each test case contains a single integer N.
For each test case, in a new line print the Catalan number at position N.
Note: Positions start from 0 as shown above.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
1 <= T <= 100
1 <= N <= 100
From the given first few Catalan's number we can easily the answer for first two test cases.
We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?
Login to access your submissions.
Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.