public class RobotMove {
    public int movingCount(int threshold, int rows, int cols)
    {
        boolean[] visited = new boolean[rows*cols];
        for(int i=0; i<rows*cols; i++){
            visited[i] = false;
        }
        int count = movingCountCore(threshold, rows, cols, 0, 0, visited);
        return count;
        
    }
    
    public int movingCountCore(int threshold, int rows, int cols, int row, int col, boolean[] visited){
        int count =0;
        if(check(threshold, rows, cols, row, col, visited)){
            visited[row*cols +col]=true;
            count = 1+movingCountCore(threshold, rows, cols, row-1, col, visited)
                + movingCountCore(threshold, rows, cols, row+1, col, visited)
                + movingCountCore(threshold, rows, cols, row, col-1, visited)
                + movingCountCore(threshold, rows, cols, row, col+1, visited);
        }
        return count;
    }
    
    public boolean check(int threshold, int rows, int cols, int row, int col, boolean[] visited){
        if(row>=0 && row<rows && col>=0 && col<cols && getDigitSum(row)+getDigitSum(col) <= threshold && !visited[row*cols+col])
            return true;
        return false;
    }
    
    public int getDigitSum(int number){
        int sum =0;
        while(number >0){
            sum+=number%10;
            number /=10;
        }
        return sum;
    }
}

@@ -916,32 +916,59 @@
 ount;%0A    %7D%0A    
+//%E7%94%A8%E6%9D%A5%E5%88%A4%E6%96%AD%E6%9C%BA%E5%99%A8%E4%BA%BA%E8%83%BD%E5%90%A6%E8%BF%9B%E5%85%A5%E5%9D%90%E6%A0%87(row,col)%E7%9A%84%E6%96%B9%E6%A0%BC
 %0A    public bool
@@ -1228,32 +1228,47 @@
 alse;%0A    %7D%0A    
+//%E7%94%A8%E6%9D%A5%E5%BE%97%E5%88%B0%E4%B8%80%E4%B8%AA%E6%95%B0%E5%AD%97%E7%9A%84%E6%95%B0%E4%BD%8D%E4%B9%8B%E5%92%8C
 %0A    public int 

Update RobotMove.java