Count of paths in a grid

Given an integer A, find and return the
number of paths in a grid of size (A x A) that starts from (1, 1) and reaches (A, A) without crossing the major diagonal.

Since the result can be large, return the result modulo (10^9 + 7).

NOTE

The major diagonal of a matrix A is the collection of entries A[i][j] where i == j



Input Format

The only argument given is integer A.

Output Format

Return the number of paths modulo (10^9 + 7).

Constraints

1 <= A <= 10^6

For Example

Input 1:
    A = 2
Output 1:
    1

Input 2:
    A = 5
Output 2:
    14
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving Count of paths in a grid on Interview Code Editor
Sign Up
to access hints and editorial solutions for Count of paths in a grid

Discussion


Loading...
Click here to start solving coding interview questions