Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6564 |

@blackshadows | 6400 |

@mb1973 | 5785 |

@Quandray | 5275 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5074 |

@kirtidee18 | 4639 |

@sanjay05 | 3762 |

@mantu_singh | 3712 |

@gfgaccount | 3627 |

@marius_valentin_dragoi | 3525 |

Complete Leaderboard | |

Handle | Score |

@yaswanthero123 | 625 |

@vikash619 | 611 |

@venkat11803610 | 501 |

@roshan13ar | 396 |

@DevangSingh | 379 |

@ravi11815721 | 312 |

@hrishipangavhane | 286 |

@aryanjain85297 | 280 |

@kommaraju11806903 | 277 |

@infosumitraut | 272 |

@ankitsharma5422 | 256 |

Complete Leaderboard |

Given a **A X B** matrix with your initial position at the top-left cell, find the number of possible unique paths to reach the bottom-right cell of the matrix from the initial position.

**Note:** Possible moves can be either **down **or **right **at any point in time, i.e., we can move to matrix[i+1][j] or matrix[i][j+1] from matrix[i][j].

**Example 1:**

**Input:
**A = 2, B = 2
**Output: **2**
Explanation:** There are only two unique
paths to reach the end of the matrix of
size two from the starting cell of the
matrix.

**Example 2:**

**Input:
**A = 3, B = 4
**Output: **10**
Explanation:** There are only 10 unique
paths to reach the end of the matrix of
size two from the starting cell of the
matrix.

**Your Task:**

Complete **NumberOfPath() **function which takes 2 arguments(A and B) and returns the number of unique paths from top-left to the bottom-right cell.

**Expected Time Complexity: **O(A*B).

**Expected Auxiliary Space: **O(A*B).

**Constraints:**

1 ≤ A ≤ 15

1 ≤ B ≤ 15

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?

YesLoading...

Number of Unique Paths

...