46. Flood Fill

Given an array image (an image), a starting position (sr, sc), and a new color color. Flood fill recolors the connected region of the original color. Return the modified image.
Example 1
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]]
Explanation: Only the connected region of 1s reachable from (1,1) is recolored.
Example 2
Input: image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, color = 0
Output: [[0,0,0],[0,0,0]]
Explanation: The starting color already equals the new color, so the image does not change.
arrayseasygraph
JavaScript
Loading...
Line 1, Char 1