Robot Delivery Path Problem

You are tasked with directing a robot from the top-left corner of an N*N matrix to a specified point (x, y), delivering a parcel. The robot is restricted to move only on flat areas (denoted by 1), and can't move on obstacles (denoted by 0). The target position is marked with a 5. Determine if it is possible for the robot to reach the destination by moving downwards or rightwards without leaving the matrix boundaries.

Input:

Integer T, the number of test cases.
For each test case -
Integer N, defining the matrix size.
Integers x and y, the destination coordinates.
N lines each containing N space-separated integers (0, 1, or 5) representing the matrix.

Output:

For each test case, return true if the robot can reach the position (x, y). Otherwise, return false.

Example:

Input:
1
3 2 2
1 0 1
1 1 1
1 1 5
Output:
true
Explanation:

The robot starts at (0,0) and moves to (2,2) following the path (0,0) -> (1,0) -> (2,0) -> (2,1) -> (2,2).

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 100
  • matrix[i][j] values are 0, 1, or 5

Note that the robot starts at position (0,0) which is always marked as 1.

AnswerBot
4mo

Determine if a robot can reach a specified destination in a matrix by moving only downwards or rightwards.

  • Start at (0,0) and move towards the destination (x, y) only downwards or rightwards.

  • Check if t...read more

Help your peers!
Select
Add answer anonymously...

Amazon Software Developer interview questions & answers

A Software Developer was asked 1mo agoQ. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ. What is MySQL?
A Software Developer was asked 1mo agoQ. What is Java?

Popular interview questions of Software Developer

A Software Developer was asked 1mo agoQ1. Could you describe the process for designing a data structure that allows for al...read more
A Software Developer was asked 1mo agoQ2. What is MySQL?
A Software Developer was asked 1mo agoQ3. What is Java?

Top HR questions asked in Amazon Software Developer

A Software Developer was asked 1mo agoQ1. Tell me about a time you had to get to the root cause of a problem
A Software Developer was asked 5mo agoQ2. What are the short-term and long-term goals for the team or organization?
A Software Developer was asked 5mo agoQ3. Why do you want to work at Amazon?
Amazon 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