Equal Sum Grid Partition I
Medium
You receive 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.
Produce true if such a partition exists; otherwise produce false.
Example 1


Input: grid = [[1,4],[2,3]]
Output: true
Explanation: 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.
Example 2
Input: grid = [[1,3],[2,4]]
Output: false
Explanation: No horizontal or vertical cut results in two non-empty sections with equal sums. Thus, the answer is false.
Constraints
1 <= m == grid.length <= 10^51 <= n == grid[i].length <= 10^52 <= m * n <= 10^51 <= grid[i][j] <= 10^5
Did this problem appear in one of your interviews?
Responses stay private.
