mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-07 09:45:04 +08:00
Fix : Floodfill infinite recursion due to same color (#4359)
Fix : Floodfill infinite recursion due to same color
This commit is contained in:
@ -39,6 +39,7 @@ public class FloodFill {
|
||||
* @param oldColor The old color which is to be replaced in the image
|
||||
*/
|
||||
public static void floodFill(int[][] image, int x, int y, int newColor, int oldColor) {
|
||||
if (newColor == oldColor) return;
|
||||
if (x < 0 || x >= image.length) return;
|
||||
if (y < 0 || y >= image[x].length) return;
|
||||
if (getPixel(image, x, y) != oldColor) return;
|
||||
|
Reference in New Issue
Block a user