mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-11 02:58:13 +08:00
55 lines
1.9 KiB
HTML
55 lines
1.9 KiB
HTML
<p>给你一个二维字符矩阵 <code>grid</code>,其中 <code>grid[i][j]</code> 可能是 <code>'X'</code>、<code>'Y'</code> 或 <code>'.'</code>,返回满足以下条件的<span data-keyword="submatrix">子矩阵</span>数量:</p>
|
||
|
||
<ul>
|
||
<li>包含 <code>grid[0][0]</code></li>
|
||
<li><code>'X'</code> 和 <code>'Y'</code> 的频数相等。</li>
|
||
<li>至少包含一个 <code>'X'</code>。</li>
|
||
</ul>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong class="example">示例 1:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">grid = [["X","Y","."],["Y",".","."]]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">3</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2024/06/07/examplems.png" style="padding: 10px; background: rgb(255, 255, 255); border-radius: 0.5rem; width: 175px; height: 350px;" /></strong></p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 2:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">grid = [["X","X"],["X","Y"]]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">0</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>不存在满足 <code>'X'</code> 和 <code>'Y'</code> 频数相等的子矩阵。</p>
|
||
</div>
|
||
|
||
<p><strong class="example">示例 3:</strong></p>
|
||
|
||
<div class="example-block">
|
||
<p><strong>输入:</strong> <span class="example-io">grid = [[".","."],[".","."]]</span></p>
|
||
|
||
<p><strong>输出:</strong> <span class="example-io">0</span></p>
|
||
|
||
<p><strong>解释:</strong></p>
|
||
|
||
<p>不存在满足至少包含一个 <code>'X'</code> 的子矩阵。</p>
|
||
</div>
|
||
|
||
<p> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li><code>1 <= grid.length, grid[i].length <= 1000</code></li>
|
||
<li><code>grid[i][j]</code> 可能是 <code>'X'</code>、<code>'Y'</code> 或 <code>'.'</code>.</li>
|
||
</ul>
|