3546. Equal Sum Grid Partition I Medium
1/**
2 * [3546] Equal Sum Grid Partition I
3 *
4 * You are given an m x n matrix grid of positive integers. Your task is to determine if it is possible to make either one horizontal or one vertical cut on the grid such that:
5 *
6 * Each of the two resulting sections formed by the cut is non-empty.
7 * The sum of the elements in both sections is equal.
8 *
9 * Return true if such a partition exists; otherwise return false.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">grid = [[1,4],[2,3]]</span>
14 * Output: <span class="example-io">true</span>
15 * Explanation:
16 * <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;" />
17 * 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 true.
18 * </div>
19 * <strong class="example">Example 2:
20 * <div class="example-block">
21 * Input: <span class="example-io">grid = [[1,3],[2,4]]</span>
22 * Output: <span class="example-io">false</span>
23 * Explanation:
24 * No horizontal or vertical cut results in two non-empty sections with equal sums. Thus, the answer is false.
25 * </div>
26 *
27 * Constraints:
28 *
29 * 1 <= m == grid.length <= 10^5
30 * 1 <= n == grid[i].length <= 10^5
31 * 2 <= m * n <= 10^5
32 * 1 <= grid[i][j] <= 10^5
33 *
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/equal-sum-grid-partition-i/
38// discuss: https://leetcode.com/problems/equal-sum-grid-partition-i/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43 pub fn can_partition_grid(grid: Vec<Vec<i32>>) -> bool {
44 false
45 }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn test_3546() {
56 }
57}
58Back
© 2026 bowen.ge All Rights Reserved.