Paths to reach origin
Easy Accuracy: 20.63% Submissions: 194 Points: 2

You are standing on a point (n, m) and you want to go to origin (0, 0) by taking steps either left or down i.e. from each point you are allowed to move either in (n-1, m) or (n, m-1). Find the number of paths from point to origin.

Example 1:


N=3, M=0
Output: 1
Explanation: Path used was - 
             (3,0)  --> ( 2,0) --> (1,0) --> (0,0).
             We can see that there is no other path
             other than this path for this testcase.


Example 2:

N=3, M=6
Output: 84 

Your Task:
Since, this is a function problem. You don't need to take any input, as it is already accomplished by the driver code. You just need to complete the function ways() that takes array N and integer M as parameters and returns the total number of paths from point(n,m) to the origin(0,0) % 1000000007.


Expected Time Complexity: O(N*M).
Expected Auxiliary Space: O(N*M).

1 ≤ N, M ≤ 500


to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Output Window