Total Unique Paths Problem Statement

You are located at point ‘A’, the top-left corner of an M x N matrix, and your target is point ‘B’, the bottom-right corner of the same matrix. Your task is to calculate the total number of unique paths from ‘A’ to ‘B’. Given the dimensions of the matrix as integers ‘M’ and ‘N’, find the total number of unique paths from MATRIX[0][0] to MATRIX[‘M’-1][‘N’-1].

Traversal Method:

Within the matrix, each move can be either Right or Down. For instance, if currently at MATRIX[i][j], you can proceed to MATRIX[i+1][j] or MATRIX[i][j+1].

Input:

The first line of input entails an integer 'T', the count of test cases. Each test case consists of a single line encompassing two space-separated integers ‘M’ and ‘N’, specifying the number of rows and columns of the matrix, respectively.

Output:

For each test case, output a single integer representing the total number of unique paths from the top-left to bottom-right cell of the matrix. Each test case output is printed on a separate line.

Example:

Input:
2
3 3
2 2
Output:
6
2

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ M ≤ 15
  • 1 ≤ N ≤ 15

Note:

No need to print anything; just implement the function to return the correct answer.

AnswerBot
2d

Calculate total unique paths from top-left to bottom-right corner of a matrix by moving only right or down.

  • Use dynamic programming to solve the problem efficiently.

  • Create a 2D array to store the numbe...read more

Help your peers!
Add answer anonymously...
Amazon Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter