mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
批量更新数据
This commit is contained in:
@@ -1,75 +1,53 @@
|
||||
<p>There is a grid with <code>n + 2</code> <strong>horizontal</strong> bars and <code>m + 2</code> <strong>vertical</strong> bars, and initially containing <code>1 x 1</code> unit cells.</p>
|
||||
<p>You are given the two integers, <code>n</code> and <code>m</code> and two integer arrays, <code>hBars</code> and <code>vBars</code>. The grid has <code>n + 2</code> horizontal and <code>m + 2</code> vertical bars, creating 1 x 1 unit cells. The bars are indexed starting from <code>1</code>.</p>
|
||||
|
||||
<p>The bars are <strong>1-indexed</strong>.</p>
|
||||
<p>You can <strong>remove</strong> some of the bars in <code>hBars</code> from horizontal bars and some of the bars in <code>vBars</code> from vertical bars. Note that other bars are fixed and cannot be removed.</p>
|
||||
|
||||
<p>You are given the two integers, <code>n</code> and <code>m</code>.</p>
|
||||
|
||||
<p>You are also given two integer arrays: <code>hBars</code> and <code>vBars</code>.</p>
|
||||
|
||||
<ul>
|
||||
<li><code>hBars</code> contains <strong>distinct</strong> horizontal bars in the range <code>[2, n + 1]</code>.</li>
|
||||
<li><code>vBars</code> contains <strong>distinct</strong> vertical bars in the range <code>[2, m + 1]</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>You are allowed to <strong>remove</strong> bars that satisfy any of the following conditions:</p>
|
||||
|
||||
<ul>
|
||||
<li>If it is a horizontal bar, it must correspond to a value in <code>hBars</code>.</li>
|
||||
<li>If it is a vertical bar, it must correspond to a value in <code>vBars</code>.</li>
|
||||
</ul>
|
||||
|
||||
<p>Return <em>an integer denoting the <strong>maximum</strong> area of a <strong>square-shaped</strong> hole in the grid after removing some bars (<strong>possibly none</strong>).</em></p>
|
||||
<p>Return an integer denoting the <strong>maximum area</strong> of a <em>square-shaped</em> hole in the grid, after removing some bars (possibly none).</p>
|
||||
|
||||
<p> </p>
|
||||
<p><strong class="example">Example 1:</strong></p>
|
||||
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/11/05/screenshot-from-2023-11-05-22-40-25.png" style="width: 411px; height: 220px;" /></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> n = 2, m = 1, hBars = [2,3], vBars = [2]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> The left image shows the initial grid formed by the bars.
|
||||
The horizontal bars are in the range [1,4], and the vertical bars are in the range [1,3].
|
||||
It is allowed to remove horizontal bars [2,3] and the vertical bar [2].
|
||||
One way to get the maximum square-shaped hole is by removing horizontal bar 2 and vertical bar 2.
|
||||
The resulting grid is shown on the right.
|
||||
The hole has an area of 4.
|
||||
It can be shown that it is not possible to get a square hole with an area more than 4.
|
||||
Hence, the answer is 4.
|
||||
</pre>
|
||||
<div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
|
||||
<p><strong>Input: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">n = 2, m = 1, hBars = [2,3], vBars = [2]</span></p>
|
||||
|
||||
<p><strong>Output: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">4</span></p>
|
||||
|
||||
<p><strong>Explanation:</strong></p>
|
||||
|
||||
<p>The left image shows the initial grid formed by the bars. The horizontal bars are <code>[1,2,3,4]</code>, and the vertical bars are <code>[1,2,3]</code>.</p>
|
||||
|
||||
<p>One way to get the maximum square-shaped hole is by removing horizontal bar 2 and vertical bar 2.</p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">Example 2:</strong></p>
|
||||
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/11/04/screenshot-from-2023-11-04-17-01-02.png" style="width: 368px; height: 145px;" /></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> n = 1, m = 1, hBars = [2], vBars = [2]
|
||||
<strong>Output:</strong> 4
|
||||
<strong>Explanation:</strong> The left image shows the initial grid formed by the bars.
|
||||
The horizontal bars are in the range [1,3], and the vertical bars are in the range [1,3].
|
||||
It is allowed to remove the horizontal bar [2] and the vertical bar [2].
|
||||
To get the maximum square-shaped hole, we remove horizontal bar 2 and vertical bar 2.
|
||||
The resulting grid is shown on the right.
|
||||
The hole has an area of 4.
|
||||
Hence, the answer is 4, and it is the maximum possible.
|
||||
</pre>
|
||||
<div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
|
||||
<p><strong>Input: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">n = 1, m = 1, hBars = [2], vBars = [2]</span></p>
|
||||
|
||||
<p><strong>Output: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">4</span></p>
|
||||
|
||||
<p><strong>Explanation:</strong></p>
|
||||
|
||||
<p>To get the maximum square-shaped hole, we remove horizontal bar 2 and vertical bar 2.</p>
|
||||
</div>
|
||||
|
||||
<p><strong class="example">Example 3:</strong></p>
|
||||
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2023/11/05/screenshot-from-2023-11-05-22-33-35.png" style="width: 648px; height: 218px;" /></p>
|
||||
<p><img alt="" src="https://assets.leetcode.com/uploads/2024/03/12/unsaved-image-2.png" style="width: 648px; height: 218px;" /></p>
|
||||
|
||||
<pre>
|
||||
<strong>Input:</strong> n = 2, m = 3, hBars = [2,3], vBars = [2,3,4]
|
||||
<strong>Output:</strong> 9
|
||||
<strong>Explanation:</strong> The left image shows the initial grid formed by the bars.
|
||||
The horizontal bars are in the range [1,4], and the vertical bars are in the range [1,5].
|
||||
It is allowed to remove horizontal bars [2,3] and vertical bars [2,3,4].
|
||||
One way to get the maximum square-shaped hole is by removing horizontal bars 2 and 3, and vertical bars 3 and 4.
|
||||
The resulting grid is shown on the right.
|
||||
The hole has an area of 9.
|
||||
It can be shown that it is not possible to get a square hole with an area more than 9.
|
||||
Hence, the answer is 9.
|
||||
</pre>
|
||||
<div class="example-block" style="border-color: var(--border-tertiary); border-left-width: 2px; color: var(--text-secondary); font-size: .875rem; margin-bottom: 1rem; margin-top: 1rem; overflow: visible; padding-left: 1rem;">
|
||||
<p><strong>Input: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">n = 2, m = 3, hBars = [2,3], vBars = [2,4]</span></p>
|
||||
|
||||
<p><strong>Output: </strong><span class="example-io" style="font-family: Menlo,sans-serif; font-size: 0.85rem;">4</span></p>
|
||||
|
||||
<p><strong>Explanation:</strong></p>
|
||||
|
||||
<p><span style="color: var(--text-secondary); font-size: 0.875rem;">One way to get the maximum square-shaped hole is by removing horizontal bar 3, and vertical bar 4.</span></p>
|
||||
</div>
|
||||
|
||||
<p> </p>
|
||||
<p><strong>Constraints:</strong></p>
|
||||
|
Reference in New Issue
Block a user