Paths in a Matrix Problem Statement

Given an 'M x N' matrix, print all the possible paths from the top-left corner to the bottom-right corner. You can only move either right (from (i,j) to (i,j+1)) or down (from (i,j) to (i+1,j)).

Example:

Input:
M = 2, N = 3
matrix = [[1, 2, 3], [4, 5, 6]]
Output:
(1 2 3 6)
(1 2 5 6)
(1 4 5 6)
Explanation:

For the given 2x3 matrix, possible paths are (1 2 3 6), (1 2 5 6), and (1 4 5 6).

Constraints:

  • 1 <= M, N <= 10
  • Time Limit: 1 sec
Note:

You can return the paths in any order. You do not need to print anything; it's already handled. Implement the function to accomplish this task.

AnswerBot
4mo

Print all possible paths from top-left to bottom-right in a matrix by moving only right or down.

  • Use backtracking to explore all possible paths from top-left to bottom-right in the matrix.

  • At each cell,...read more

Help your peers!
Select
Add answer anonymously...

Virtusa Consulting Services Software Developer interview questions & answers

A Software Developer was asked 2mo agoQ. What Java testing have you done?
A Software Developer was asked 5mo agoQ. What is encapsulation?
A Software Developer was asked 5mo agoQ. What is a copy constructor?

Popular interview questions of Software Developer

A Software Developer was asked 2mo agoQ1. What Java testing have you done?
A Software Developer was asked 5mo agoQ2. What is encapsulation?
A Software Developer was asked 5mo agoQ3. What was your experience in developing a pharmacy inventory management web appli...read more

Top HR questions asked in Virtusa Consulting Services Software Developer

A Software Developer was asked 4mo agoQ1. What are your salary expectations?
A Software Developer was asked 4mo agoQ2. What do you know about the company?
A Software Developer was asked 7mo agoQ3. Are you willing to relocate?
Virtusa Consulting Services 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