1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 08:21:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/等和矩阵分割 I [equal-sum-grid-partition-i].html
2025-05-15 01:05:54 +08:00

50 lines
1.7 KiB
HTML
Raw Permalink 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>m x n</code> 矩阵 <code>grid</code>。你的任务是判断是否可以通过&nbsp;<strong>一条水平或一条垂直分割线&nbsp;</strong>将矩阵分割成两部分,使得:</p>
<ul>
<li>分割后形成的每个部分都是&nbsp;<strong>非空&nbsp;</strong>的。</li>
<li>两个部分中所有元素的和&nbsp;<strong>相等&nbsp;</strong></li>
</ul>
<p>如果存在这样的分割,返回 <code>true</code>;否则,返回 <code>false</code></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> grid = [[1,4],[2,3]]</p>
<p><strong>输出:</strong> true</p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://pic.leetcode.cn/1746839596-kWigaF-lc.jpeg" style="height: 200px; width: 200px;" /></p>
<p>在第 0 行和第 1 行之间进行水平分割,得到两个非空部分,每部分的元素之和为 5。因此答案是 <code>true</code></p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> grid = [[1,3],[2,4]]</p>
<p><strong>输出:</strong> false</p>
<p><strong>解释:</strong></p>
<p>无论是水平分割还是垂直分割,都无法使两个非空部分的元素之和相等。因此,答案是 <code>false</code></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= m == grid.length &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= n == grid[i].length &lt;= 10<sup>5</sup></code></li>
<li><code>2 &lt;= m * n &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= grid[i][j] &lt;= 10<sup>5</sup></code></li>
</ul>
<p>&nbsp;</p>