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

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 this problem efficiently.

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

Help your peers!
Select
Add answer anonymously...

Top Software Developer Intern Interview Questions Asked at Atlassian

Q. Design an API service to limit the number of accesses for a user to a function w...read more
Q. Longest increasing subsequence
Q. Ninja and Geometry Problem Statement In this problem, Ninja is provided with two...read more
Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

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

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits