import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static void printShortestPath(int n, int x, int y, int p, int q, int count, List arr) { if(p == x && q == y){ System.out.println(count); String paths[] = new String[arr.size()]; arr.toArray(paths); for(int i=0; i=0 && y>=0){ x = x-2; y = y-1; arr.add("UL"); count++; printShortestPath(n,x,y,p,q,count,arr); } else if(py && x>=0 && y<=n){ x = x-2; y = y+1; arr.add("UR"); count++; printShortestPath(n,x,y,p,q,count,arr); } else if(p==x && q=0){ y = y-2; arr.add("L"); count++; printShortestPath(n,x,y,p,q,count,arr); } else if(p == x && q > y && x=0){ y = y+2; arr.add("R"); count++; printShortestPath(n,x,y,p,q,count,arr); } else if(p>x && q=0){ x = x+2; y = y-1; arr.add("LL"); count++; printShortestPath(n,x,y,p,q,count,arr); } else if(p>x && q>y && xx && q==y && x arr = new ArrayList(); printShortestPath(n, i_start, j_start, i_end, j_end, count, arr); in.close(); } }