Live Batches
Masterclasses
Menu
Free Courses
Account
Login / Sign Up
Problem Submissions Solution

Rat In A Maze

Difficulty: Hard

Acceptance: 38.00%

Points: 40.00

Description: A rat is placed at position (0, 0) in an n × n square matrix maze[][]. The goal is to reach the destination (n-1, n-1). Each cell contains: 1 ? free cell (can move) 0 ? blocked cell (cannot move) The rat can move in four directions: U (Up), D (Down), L (Left), R (Right) The rat cannot visit the same cell more than once in a path and can only move inside the grid through free cells. Return all valid paths in lexicographically sorted order. If no path exists, return an empty list.

Topics

Companies

Articles

Examples:

N/A

Constraints:
  • 2 = n = 5
  • 0 = maze[i][j] = 1
Companies:
Amazon Microsoft Apple Samsung Visa + 1 more
Topics:
Recursion
Locked Content
Access Restricted: Please Login to access the code editor and test cases.