mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
23 lines
1.3 KiB
HTML
23 lines
1.3 KiB
HTML
<p>Implement the "paint fill" function that one might see on many image editing programs. That is, given a screen (represented by a two-dimensional array of colors), a point, and a new color, fill in the surrounding area until the color changes from the original color.</p>
|
|
|
|
|
|
|
|
<p><strong>Example1:</strong></p>
|
|
|
|
|
|
|
|
<pre>
|
|
|
|
<strong>Input</strong>:
|
|
|
|
image = [[1,1,1],[1,1,0],[1,0,1]]
|
|
|
|
sr = 1, sc = 1, newColor = 2
|
|
|
|
<strong>Output</strong>: [[2,2,2],[2,2,0],[2,0,1]]
|
|
|
|
<strong>Explanation</strong>:
|
|
|
|
From the center of the image (with position (sr, sc) = (1, 1)), all pixels connected
|
|
|
|
by a path of the same color as the starting pixel are colored with the new color.
|
|
|
|
Note the bottom corner is not colored 2, because it is not 4-directionally connected
|
|
|
|
to the starting pixel.</pre>
|
|
|
|
|
|
|
|
<p><b>Note:</b></p>
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>The length of <code>image</code> and <code>image[0]</code> will be in the range <code>[1, 50]</code>.</li>
|
|
|
|
<li>The given starting pixel will satisfy <code>0 <= sr < image.length</code> and <code>0 <= sc < image[0].length</code>.</li>
|
|
|
|
<li>The value of each color in <code>image[i][j]</code> and <code>newColor</code> will be an integer in <code>[0, 65535]</code>.</li>
|
|
|
|
</ul>
|
|
|