1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-12 10:51:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

批量更新数据

This commit is contained in:
2025-01-09 20:29:41 +08:00
parent 04ecea043d
commit 48cdd06c2b
5053 changed files with 156164 additions and 135322 deletions

View File

@@ -1,10 +1,15 @@
<p>有一幅以&nbsp;<code>m x n</code>&nbsp;的二维整数数组表示的图画&nbsp;<code>image</code>&nbsp;,其中&nbsp;<code>image[i][j]</code>&nbsp;表示该图画的像素值大小。</p>
<p>有一幅以&nbsp;<code>m x n</code>&nbsp;的二维整数数组表示的图画&nbsp;<code>image</code>&nbsp;,其中&nbsp;<code>image[i][j]</code>&nbsp;表示该图画的像素值大小。你也被给予三个整数 <code>sr</code> ,&nbsp; <code>sc</code><code>color</code> 。你应该从像素&nbsp;<code>image[sr][sc]</code>&nbsp;开始对图像进行上色&nbsp;<strong>填充</strong></p>
<p>你也被给予三个整数 <code>sr</code> ,&nbsp; <code>sc</code><code>newColor</code> 。你应该从像素&nbsp;<code>image[sr][sc]</code>&nbsp;开始对图像进行 上色<strong>填充</strong></p>
<p>为了完成 <strong>上色工作</strong></p>
<p>为了完成<strong> 上色工作</strong> ,从初始像素开始,记录初始坐标的 <strong>上下左右四个方向上</strong> 像素值与初始坐标相同的相连像素点,接着再记录这四个方向上符合条件的像素点与他们对应 <strong>四个方向上</strong> 像素值与初始坐标相同的相连像素点,……,重复该过程。将所有有记录的像素点的颜色值改为&nbsp;<code>newColor</code>&nbsp;</p>
<ol>
<li>从初始像素开始,将其颜色改为 <code>color</code></li>
<li>对初始坐标的 <strong>上下左右四个方向上</strong> 相邻且与初始像素的原始颜色同色的像素点执行相同操作。</li>
<li>通过检查与初始像素的原始颜色相同的相邻像素并修改其颜色来继续 <strong>重复</strong> 此过程。</li>
<li><strong>没有</strong> 其它原始颜色的相邻像素时 <strong>停止</strong> 操作。</li>
</ol>
<p>最后返回 <em>经过上色渲染后的图像&nbsp;</em></p>
<p>最后返回经过上色渲染&nbsp;<strong>修改</strong> 后的图像&nbsp;</p>
<p>&nbsp;</p>
@@ -12,19 +17,23 @@
<p><img src="https://assets.leetcode.com/uploads/2021/06/01/flood1-grid.jpg" /></p>
<pre>
<strong>输入:</strong> image = [[1,1,1],[1,1,0],[1,0,1]]sr = 1, sc = 1, newColor = 2
<strong>输出:</strong> [[2,2,2],[2,2,0],[2,0,1]]
<strong>解析:</strong> 在图像的正中间,(坐标(sr,sc)=(1,1)),在路径上所有符合条件的像素点的颜色都被更改成2。
注意右下角的像素没有更改为2因为它不是在上下左右四个方向上与初始点相连的像素点。
</pre>
<div class="example-block"><strong>输入:</strong>image = [[1,1,1],[1,1,0],[1,0,1]]sr = 1, sc = 1, color = 2</div>
<div class="example-block"><strong>输出</strong>[[2,2,2],[2,2,0],[2,0,1]]</div>
<div class="example-block"><b>解释:</b>在图像的正中间,坐标 <code>(sr,sc)=(1,1)</code>&nbsp;(即红色像素),在路径上所有符合条件的像素点的颜色都被更改成相同的新颜色(即蓝色像素)。</div>
<div class="example-block">注意,右下角的像素 <strong>没有</strong> 更改为2因为它不是在上下左右四个方向上与初始点相连的像素点。</div>
<div class="example-block">&nbsp;</div>
<p><strong>示例 2:</strong></p>
<pre>
<strong>输入:</strong> image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, newColor = 2
<strong>输出:</strong> [[2,2,2],[2,2,2]]
</pre>
<div class="example-block"><strong>输入:</strong>image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, color = 0</div>
<div class="example-block"><strong>输出</strong>[[0,0,0],[0,0,0]]</div>
<div class="example-block"><strong>解释:</strong>初始像素已经用 0 着色,这与目标颜色相同。因此,不会对图像进行任何更改。</div>
<p>&nbsp;</p>
@@ -34,7 +43,7 @@
<li><code>m == image.length</code></li>
<li><code>n == image[i].length</code></li>
<li><code>1 &lt;= m, n &lt;= 50</code></li>
<li><code>0 &lt;= image[i][j], newColor &lt; 2<sup>16</sup></code></li>
<li><code>0 &lt;= image[i][j], color &lt; 2<sup>16</sup></code></li>
<li><code>0 &lt;= sr &lt;&nbsp;m</code></li>
<li><code>0 &lt;= sc &lt;&nbsp;n</code></li>
</ul>