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

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

Help your peers!
Select
Add answer anonymously...

Amazon Software Developer Intern interview questions & answers

A Software Developer Intern was asked 4mo agoQ. Given a linked list, find the n'th node from the end of the list.
A Software Developer Intern was asked 4mo agoQ. Given a tree, find its diameter (the longest path between two nodes in the tree)...read more
A Software Developer Intern was asked 4mo agoQ. Given a matrix, find the shortest distance between two given points located anyw...read more

Popular interview questions of Software Developer Intern

A Software Developer Intern was asked 4mo agoQ1. Given a linked list, find the n'th node from the end of the list.
A Software Developer Intern was asked 4mo agoQ2. Given a tree, find its diameter (the longest path between two nodes in the tree)...read more
A Software Developer Intern was asked 4mo agoQ3. Given a matrix, find the shortest distance between two given points located anyw...read more
Amazon 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