• Source
    1. /* package whatever; // don't place package name! */
    2.  
    3. import java.util.*;
    4. import java.lang.*;
    5. import java.io.*;
    6.  
    7. /* Name of the class has to be "Main" only if the class is public. */
    8. class Ideone
    9. {
    10.  
    11. int helper(int[][] table, int i, int j) {
    12. if ( i < 0 || j < 0 || i >= 4 || j >= 4 ) return 0;
    13. if ( table[i][j] == 1 ) return 0;
    14. if ( i == 3 && j == 3 ) return 1;
    15.  
    16. table[i][j] = 1;
    17. return helper(table, i, j+1) + helper(table, i+1, j) + helper(table, i, j-1) + helper(table, i-1, j);
    18. }
    19.  
    20. public static void main (String[] args) throws java.lang.Exception
    21. {
    22. // your code goes here
    23. int[][] table=new int[4][4];
    24. for(int i=0; i<4; i++)
    25. for(int j=0; j<4; j++) table[i][j]=0;
    26. System.out.println(new Ideone().helper(table,0,0));
    27. }
    28. }