Handle Score
@Ibrahim Nash 6420
@blackshadows 6380
@mb1973 5646
@Quandray 5233
@akhayrutdinov 5111
@saiujwal13083 4716
@sanjay05 3762
@kirtidee18 3673
@marius_valentin_dragoi 3522
@sushant_a 3459
@verma_ji 3413
Complete Leaderboard
Paths to reach origin
Easy Accuracy: 35.13% Submissions: 744 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.

Paths to reach origin

Output Window