Unique Paths Problem Statement

Given the dimensions of an M x N matrix, determine the total number of unique paths from the top-left corner to the bottom-right corner of the matrix.

Allowed moves are only to the right or down at each step.

Input:

The first line contains an integer 'T', the number of test cases.
For each test case, a single line contains two space-separated integers 'M' and 'N', representing 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 the bottom-right cell of the matrix.
Print the output for each test case on a new line.

Example:

Input:
T = 2
M = 2, N = 2
M = 3, N = 3
Output:
2
6

Constraints:

  • 1 ≤ T ≤ 100
  • 1 ≤ M ≤ 15
  • 1 ≤ N ≤ 15
  • The time limit is 1 second

Note:

There is no need for you to print anything; simply implement the function to compute the results.
AnswerBot
4mo

The problem involves finding the total number of unique paths from the top-left corner to the bottom-right corner of an M x N matrix by moving only right or down.

  • Use dynamic programming to solve this ...read more

Help your peers!
Select
Add answer anonymously...

Top Software Developer Interview Questions Asked at Amazon

Q. What is OOPS?
Q. What is Java programming?
Q. Could you describe the process for designing a data structure that allows for al...read more
Software Developer 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