Flood Fill
Try to solve the Flood Fill problem.
We'll cover the following
Statement
We are given the following values as input to begin with:
The coordinates of a source cell, i.e.,
sr
andsc
.A target value,
target
.An
grid.
Our task is to perform flood fill by updating the values of the four directionally connected cells, which have the same value as the source cell with the target value.
How to perform flood fill:
Suppose that a
If no neighboring cell has a value equal to the source cell, only update the source cell with the target value and return the updated grid.
Constraints:
grid.length
,grid[i].length
grid[i][j]
,target
sr
grid.length
sc
grid[i].length
Examples
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy