The problem I am talking about is the one below :
Consider a rat placed at (0, 0) in a square matrix m[ ][ ] of order n and has to reach the destination at (n-1, n-1).
The task is to find a sorted array of strings denoting all the possible directions which the rat can take to reach the destination at (n-1, n-1).
The directions in which the rat can move are ‘U'(up), ‘D'(down), ‘L’ (left), ‘R’ (right).
You cannot visit an already visited cell.
Examples:
Input : N = 4
1 0 0 0
1 1 0 1
0 1 0 0
0 1 1 1
Output :
DRDDRR
Input :N = 4
1 0 0 0
1 1 0 1
1 1 0 0
0 1 1 1
Output :
DDRDRR DRDDRR
Why cannot it be solved by dynamic programming? Can't we store all path strings from a given cell?