Equal Sum Grid Partition I
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:
- Each of the two resulting sections formed by the cut is non-empty.
- The sum of the elements in both sections is equal.
Return true if such a partition exists; otherwise return false.
Example 1
1 4 2 3
Input
grid = [[1,4],[2,3]]Output
trueA horizontal cut between row 0 and row 1 results in two non-empty sections, each with a sum of 5.
Example 2
1 3 2 4
Input
grid = [[1,3],[2,4]]Output
falseNo horizontal or vertical cut results in two non-empty sections with equal sums.
Constraints
- 1 <= m == grid.length <= 10^5
- 1 <= n == grid[i].length <= 10^5
- 2 <= m * n <= 10^5
- 1 <= grid[i][j] <= 10^5