Ninja and the Maze Problem Statement
Ninja is stuck in a maze represented as a 2D grid. He can move in four directions (Up, Down, Left, Right) until he hits a wall ('1'). Once stopped, he can choose a new direction. Determine if Ninja can reach the destination from the starting point.
Example:
Input:
maze = [[0, 0, 1], [1, 0, 0], [1, 0, 0]]
start = [2, 2]
destination = [0, 0]
Output:
True
Explanation:
Ninja can reach the destination using paths such as [left -> up -> left] or [up -> left -> up -> left].
Input:
The first line contains an integer ‘T’ denoting number of test cases.
Each test case includes:
- Two integers ‘M’ and ‘N’ marking maze dimensions.
- An ‘M’x‘N’ matrix representing the maze.
- Two integers for starting point coordinates.
- Two integers for destination coordinates.
Output:
For each test case, print 'True' if path exists, otherwise 'False'.
Constraints:
- 1 <= T <= 50
- 1 <= M, N <= 100
- 0 <= MAZE[i][j] <= 1
Note:
No need to print; focus on implementing the function.
Anonymous
1mo
Preafare
Help your peers!
Add answer anonymously...
Top Bounteous x Accolite Software Developer Intern interview questions & answers
Popular interview questions of Software Developer Intern
Top HR questions asked in Bounteous x Accolite Software Developer Intern
>
Bounteous x Accolite Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app