Internal Error : OJ is not showing info related to this? what causes this error, any guess?


  • 2
    R

    Here is my code:

    final static int rowMax = 100;
    final static int colMax = 100;
    int memorize[][] = new int[rowMax+2][colMax+2];
    
    public int uniquePathsWithObstacles(int[][] obstacleGrid) {
          Object orly = obstacleGrid;
    	  int nDim =2;
    	  int m =0;
    	  int n = 0;
    	  
    	    for (int i =0; i< nDim ;i++){
    	    	int len = Array.getLength(orly);
    	    	System.out.println("dim[" + i + "]=" + len);
    	    	if( i == 0){
    	    		m = len;
    	    	}else
    	    	{
    	    		n = len;
    	    	}
    	    	if(0<len){
    	    		orly = Array.get(orly, 0);
    	    	}
    	    }
    	    	if(m == 0 || n ==0)	    {
    	    	    return 0;
    	    	}
    	 return uniquePaths(m,n,obstacleGrid);
    }
    
    public int uniquePaths(int m, int n,int[][] obstacleGrid) {
    	initializeMemorize();
           return uniquePaths(m,n,1,1,obstacleGrid);
    }
        
        
    private int  uniquePaths(int m, int n, int row, int column,int[][] obstacleGrid){
    	if(row == m && column == n){
    		return 1;
    	}
    	if(row > m || column > n ){
    		return 0;
    	}
    	if(obstacleGrid[row-1][column-1] == 1){
    		return 0;
    	}
    	if(memorize[row+1][column] == -1){
    		memorize[row+1][column] =uniquePaths(m,n,row+1,column,obstacleGrid);			
    	}
    	if(memorize[row][column+1] == -1){
    		memorize[row][column+1] =uniquePaths(m,n,row,column+1,obstacleGrid);
    	}
    	return memorize[row+1][column] + memorize[row][column+1];
    }
    
    private void initializeMemorize(){
    	for(int i=0;i<rowMax;i++){
    		for(int j=0;j<colMax;j++){
    			memorize[i][j]= -1;
    		}
    	}
    }

  • 2
    S

    Usually, it happends when you do std output in your code.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.