#3546

Equal Sum Grid Partition I

medium · 42.3% accepted · 78 likes · top 23%

array · matrix · enumeration · prefix sum

Description

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.

Solution