image is a grid of colours. Starting at the cell (sr, sc), recolour it and every cell connected to it (up, down, left or right) that has the same original colour to color. Return the new image.
For image = [[1, 1, 1], [1, 1, 0], [1, 0, 1]], (sr, sc) = (1, 1) and color = 2 the answer is [[2, 2, 2], [2, 2, 0], [2, 0, 1]].
Example 1
Input:
flood_fill([[1, 1, 1], [1, 1, 0], [1, 0, 1]], 1, 1, 2)
Output:
[[2, 2, 2], [2, 2, 0], [2, 0, 1]]
Example 2
Input:
flood_fill([[0, 0, 0], [0, 0, 0]], 0, 0, 0)
Output:
[[0, 0, 0], [0, 0, 0]]
1 <= rows, cols <= 3000 <= image[i][j], color < 65536(sr, sc) is a cell of the image.No results yet
Run your code to check it against the examples, or submit to run every test.