package leetcode;

/**
 * https://leetcode.com/problems/flood-fill/
 */
public class Problem733 {
    public int[][] floodFill(int[][] image, int sr, int sc, int newColor) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem733 prob = new Problem733();
        System.out.println(prob.floodFill(new int[][]{
            {1, 1, 1},
            {1, 1, 0},
            {1, 0, 1}}, 1, 1, 2)); // [[2,2,2],[2,2,0],[2,0,1]]
    }
}

@@ -179,15 +179,281 @@
     
-// TODO
+int maxRow = image.length;%0A        int maxCol = 0;%0A        if (image.length %3E 0) %7B%0A            maxCol = image%5B0%5D.length;%0A        %7D%0A        boolean%5B%5D%5B%5D visited = new boolean%5BmaxRow%5D%5BmaxCol%5D;%0A        floodFill(image, sr, sc, newColor, image%5Bsr%5D%5Bsc%5D, maxRow, maxCol, visited);
 %0A   
@@ -468,12 +468,13 @@
 urn 
-null
+image
 ;%0A  
@@ -483,21 +483,22 @@
 %7D%0A%0A    p
-ublic
+rivate
  static 
@@ -506,238 +506,918 @@
 oid 
-main(String%5B%5D args) %7B%0A        Problem733 prob = new Problem733();%0A        System.out.println(prob.floodFill(new int%5B%5D%5B%5D%7B%0A            %7B1, 1, 1%7D,%0A            %7B1, 1, 0%7D,%0A            %7B1, 0, 1%7D%7D, 1, 1, 2)); // %5B%5B2,2,2%5D,%5B2,2,0%5D,%5B2,0,1%5D%5D
+floodFill(int%5B%5D%5B%5D image, int row, int col, int newColor, int originalColor,%0A                                  int maxRow, int maxCol, boolean%5B%5D%5B%5D visited) %7B%0A        if (row %3C 0 %7C%7C col %3C 0 %7C%7C row %3E= maxRow %7C%7C col %3E= maxCol) %7B%0A            return;%0A        %7D%0A        if (visited%5Brow%5D%5Bcol%5D) %7B%0A            return;%0A        %7D%0A        visited%5Brow%5D%5Bcol%5D = true;%0A        if (image%5Brow%5D%5Bcol%5D == originalColor) %7B%0A            image%5Brow%5D%5Bcol%5D = newColor;%0A        %7D else %7B%0A            return;%0A        %7D%0A        // top%0A        floodFill(image, row - 1, col, newColor, originalColor, maxRow, maxCol, visited);%0A        // right%0A        floodFill(image, row, col + 1, newColor, originalColor, maxRow, maxCol, visited);%0A        // down%0A        floodFill(image, row + 1, col, newColor, originalColor, maxRow, maxCol, visited);%0A        // left%0A        floodFill(image, row, col - 1, newColor, originalColor, maxRow, maxCol, visited);
 %0A   

Solve problem 733