#733

Flood Fill

pupil · 310 · lc easy +21 · 67.9% accepted · 9,413 likes · top 74%

Description

You are given an m x n pixel grid image along with a starting pixel (sr, sc) and a target color. Apply a flood fill starting from image[sr][sc]: repaint it and all 4-directionally connected pixels that share its original color to the new color, continuing recursively until no more matching adjacent pixels remain.

Return the updated image.

Code

1
2
3