Back to course home
0% completed
Vote For New Content
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
Comments
A
Anthony DiFede3 years ago
Thinking the same thing
F
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.
M
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
Try it yourself