Rat in a Maze
00:00
TCSWiproAmazon
Find all paths for a rat to travel from top-left to bottom-right of n×n grid. Can move in 4 directions (U,D,L,R). Cell value 1=open, 0=blocked.
Examples
Input → [[1,0,0,0],[1,1,0,1],[1,1,0,0],[0,1,1,1]]
Output → ['DDRDRR','DRDDRR']
Input → [[0]]
Output → []
Input → [[1,1],[1,1]]
Output → ['DR','RD']