Geeksforgeeks

Error

×

Leaderboard

Showing:

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 | |

Handle | Score |

@skj7 | 671 |

@gurshehzadsingh | 418 |

@swastik8750 | 411 |

@nishunishuraj18 | 405 |

@vedantvalsangkar | 390 |

@deepakchowdary | 380 |

@akashverma4 | 369 |

@satyamannsm | 353 |

@2018uec1603 | 333 |

@rkrupeshkumar345 | 331 |

@surajmamgai | 330 |

Complete Leaderboard |

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:**

Input:N=3, M=0Output:1Explanation: 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:**

**Input:
**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).

**Constraints:**

1 ≤ N, M ≤ 500

Login 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?

Yes
Paths to reach origin

...