1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/统计 X 和 Y 频数相等的子矩阵数量 [count-submatrices-with-equal-frequency-of-x-and-y].html
2024-07-16 16:03:30 +08:00

55 lines
1.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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>&nbsp;</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>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= grid.length, grid[i].length &lt;= 1000</code></li>
<li><code>grid[i][j]</code> 可能是 <code>'X'</code><code>'Y'</code><code>'.'</code>.</li>
</ul>