Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static void paintFill(int[][] image, int x, int y, int oldColor, int newColor) {
if (x < 0 || x == image[0].length || y < 0 || y == image.length) {
return;
}
if (image[y][x] == oldColor) {
image[y][x] = newColor;
paintFill(image, x + 1, y, oldColor, newColor);
paintFill(image, x - 1, y, oldColor, newColor);
paintFill(image, x, y + 1, oldColor, newColor);
paintFill(image, x, y - 1, oldColor, newColor);
}
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.