LeetCode: https://leetcode.com/problems/flood-fill/
An image is represented by an m x n integer grid image where image[i][j] represents the pixel value.
Perform a flood fill starting from (sr, sc), replacing the starting pixel's color and all connected pixels of the same color with color.
Example:
- Input:
image = [[1,1,1],[1,1,0],[1,0,1]], sr = 1, sc = 1, color = 2 - Output:
[[2,2,2],[2,2,0],[2,0,1]]
1
1
1
1
2
0
1
0
1
sr=1
sc=1
start=1
color=2
Step 1 / 3
Step 1:
Record the start color, repaint the start cell, and DFS/BFS outward to same-colored neighbors.
Focus: select @ [4]
sr=1sc=1start=1color=2