mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 09:21:40 +08:00
46 lines
1.9 KiB
HTML
46 lines
1.9 KiB
HTML
<p>You are given an <code>m x n</code> matrix <code>grid</code> of positive integers. Your task is to determine if it is possible to make <strong>either one horizontal or one vertical cut</strong> on the grid such that:</p>
|
|
|
|
<ul>
|
|
<li>Each of the two resulting sections formed by the cut is <strong>non-empty</strong>.</li>
|
|
<li>The sum of the elements in both sections is <strong>equal</strong>.</li>
|
|
</ul>
|
|
|
|
<p>Return <code>true</code> if such a partition exists; otherwise return <code>false</code>.</p>
|
|
|
|
<p> </p>
|
|
<p><strong class="example">Example 1:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">grid = [[1,4],[2,3]]</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">true</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p><img alt="" src="https://assets.leetcode.com/uploads/2025/03/30/lc.png" style="width: 200px;" /><img alt="" src="https://assets.leetcode.com/uploads/2025/03/30/lc.jpeg" style="width: 200px; height: 200px;" /></p>
|
|
|
|
<p>A horizontal cut between row 0 and row 1 results in two non-empty sections, each with a sum of 5. Thus, the answer is <code>true</code>.</p>
|
|
</div>
|
|
|
|
<p><strong class="example">Example 2:</strong></p>
|
|
|
|
<div class="example-block">
|
|
<p><strong>Input:</strong> <span class="example-io">grid = [[1,3],[2,4]]</span></p>
|
|
|
|
<p><strong>Output:</strong> <span class="example-io">false</span></p>
|
|
|
|
<p><strong>Explanation:</strong></p>
|
|
|
|
<p>No horizontal or vertical cut results in two non-empty sections with equal sums. Thus, the answer is <code>false</code>.</p>
|
|
</div>
|
|
|
|
<p> </p>
|
|
<p><strong>Constraints:</strong></p>
|
|
|
|
<ul>
|
|
<li><code>1 <= m == grid.length <= 10<sup>5</sup></code></li>
|
|
<li><code>1 <= n == grid[i].length <= 10<sup>5</sup></code></li>
|
|
<li><code>2 <= m * n <= 10<sup>5</sup></code></li>
|
|
<li><code>1 <= grid[i][j] <= 10<sup>5</sup></code></li>
|
|
</ul>
|