@@ -0,0 +1,1376 @@
+import java.util.Arrays;%0A%0Apublic class RobotMove %7B%0A%0A%09%0A%09public int movingCount(int threshold, int rows, int cols) %7B%0A%09%09boolean%5B%5D visited = new boolean%5Brows*cols%5D;%0A%09%09Arrays.fill(visited, false);%0A%09%09%0A%09%09int count = movingCountCore(threshold, rows, cols, 0, 0, visited);%0A%09%09return count;%0A%09%7D%0A%0A%09private int movingCountCore(int threshold, int rows, int cols, int row, int col, boolean%5B%5D visited) %7B%0A%09%09int count = 0;%0A%09%09if (check(threshold, rows, cols, row, col, visited)) %7B%0A%09%09%09visited%5Brow*cols + col%5D = true;%0A%09%09%09%0A%09%09%09count = 1 + %0A%09%09%09%09%09movingCountCore(threshold, rows, cols, row-1, col, visited) +%0A%09%09%09%09%09movingCountCore(threshold, rows, cols, row, col-1, visited) +%0A%09%09%09%09%09movingCountCore(threshold, rows, cols, row+1, col, visited) +%0A%09%09%09%09%09movingCountCore(threshold, rows, cols, row, col+1, visited);%0A%09%09%7D%0A%09%09return count;%0A%09%7D%0A%0A%09private boolean check(int threshold, int rows, int cols, int row, int col, boolean%5B%5D visited) %7B%0A%09%09if (row %3E= 0 && row %3C rows && col %3E= 0 && col %3C cols && %0A%09%09    (getDigitSum(row) + getDigitSum(col)) %3C= threshold &&%0A%09%09    !visited%5Brow*cols+col%5D)%0A%09%09%09return true;%0A%09%09return false;%0A%09%7D%0A%0A%09private int getDigitSum(int number) %7B%0A%09%09int sum = 0;%0A%09%09while (number %3E 0) %7B%0A%09%09%09sum += number %25 10;%0A%09%09%09number /= 10;%0A%09%09%7D%0A%09%09return sum;%0A%09%7D%0A%09%0A%09public static void main(String%5B%5D args) %7B%0A%09%09StringPathInMatrix s = new StringPathInMatrix();%0A%09%09System.out.println(s.movingCount(15, 20, 20));%0A%09%7D%0A%7D%0A

Create 067_RobotMove.java