
N = 2

For n = 2, there can be three possible moves, as shown in the figure. Hence the answer is 3.
The first line contains a single integer ‘T’ denoting the number of test cases, then each test case follows:
The first line of each test case contains a single integer ‘N’ denoting the size of the square matrix.
For each test case, print a single integer “ans” denoting the total number of paths.
Output for each test case will be printed in a separate line.
You are not required to print anything; it has already been taken care of. Just implement the function.
1 <= T <= 10
1 <= N <= 500
Time limit: 1 sec
In this approach, we will start from the (N - 1, 0) and add all the possible paths for down, left, and down-left.
The steps are as follows:
In this approach, we will start from the (N - 1, 0) and add all the possible paths for down, left, and down-left and store all the values in a 2D array “dp”.
The steps are as follows:
In this approach, we will take a 2D array “dp”, where “dp[i][j]” will store the total number of paths from (n - 1, 0) to (i, j).
The steps are as follows: