Question: Consider a rat placed at (0,0) in a square matrix mDU of order n and has to reach the destination at (n1,n1). The indexing starts

 Consider a rat placed at (0,0) in a square matrix mDU

of order n and has to reach the destination at (n1,n1). The

Consider a rat placed at (0,0) in a square matrix mDU of order n and has to reach the destination at (n1,n1). The indexing starts from 0 . Your task is to write code which prints a sorted array of strings denoting all the possible directions which the rat can take to reach the destination at (n1,n1). The directions in which the rat can move are 'D'(down) and 'R' (right). Output will be space separated sorted strings denoting all directions, which the rat could take to reach the destination. import java.util.*; class Testclass \{ static List v= new ArrayList(); static void printPath(int m[][], int n ) \{ //write your code here \} public static void main(String[] args) \{ TestClass obj = new TestClass (); Scanner in = new Scanner(System.in); int n=in.nextInt(); int ar[][]= new int[n][n]; for (int i=0;i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!