0% completed
I was wondering for flood fill Easy, why are these 2 checks different and affect...
Elaine Michelle Teh
Nov 16, 2022
I was wondering for flood fill Easy, why are these 2 checks different and affect the code so much in fillDFS?

0
0
Comments
Anthony DiFede3 years ago
Thinking the same thing
First 3 years ago
You don't need to check the first condition because we have this line: if (matrix[x][y] !== oldColor), so we are only going to care about a square if it has the oldColor. We are essentially seeking out only oldColors that are within reach.
Mike Xu3 years ago
The old color check is to make sure that you still need to continue flood filling as matrix[x][y] is still in the blob of old color that you want to flood fill.
On the other hand, if there's nothing on the input image with the new color, the new color check will never ...
On this page
Problem Statement
Solution
Code (DFS)
Time Complexity
Space Complexity