Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Rat in a Maze

A rat starts at the top-left cell of an n x n maze and must reach the bottom-right cell. A cell value of 1 is open and 0 is blocked. The rat may move Down (D), Left (L), Right (R) or Up (U) and may not visit a cell twice on the same path. Print all paths in lexicographic order, one per line, or -1 if there is none.

Constraints

2 <= n <= 8

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.