Tap here to switch tabs
Problem
Submissions

Problem: Equal Sum Grid Partition II

Try to solve the Equal Sum Grid Partition II problem.

Statement

Given a 22D integer array grid of size m ×\times n.

A partition is formed by making a single straight horizontal or vertical cut that divides grid into two non-empty rectangular subgrids.

You may optionally remove at most 11 cell from at most 11 of the two subgrids. A partition is valid if:

  • The sum of values in both subgrids is equal after the optional cell removal.

  • If a cell is removed, the remaining cells in that subgrid must remain non-empty and form a single 44-directionally connected component.

Return true if there exists at least 11 valid partition, or false otherwise.

Note: Two cells are considered connected if they share an edge.

Constraints:

  • 1≤1 \leq m ==== grid.length ≤105\leq 10^5

  • 1≤1 \leq n ==== grid[i].length ≤105\leq 10^5

  • 2≤2 \leq m * n ≤105\leq 10^5

  • 1≤1 \leq grid[i][j] ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Equal Sum Grid Partition II

Try to solve the Equal Sum Grid Partition II problem.

Statement

Given a 22D integer array grid of size m ×\times n.

A partition is formed by making a single straight horizontal or vertical cut that divides grid into two non-empty rectangular subgrids.

You may optionally remove at most 11 cell from at most 11 of the two subgrids. A partition is valid if:

  • The sum of values in both subgrids is equal after the optional cell removal.

  • If a cell is removed, the remaining cells in that subgrid must remain non-empty and form a single 44-directionally connected component.

Return true if there exists at least 11 valid partition, or false otherwise.

Note: Two cells are considered connected if they share an edge.

Constraints:

  • 1≤1 \leq m ==== grid.length ≤105\leq 10^5

  • 1≤1 \leq n ==== grid[i].length ≤105\leq 10^5

  • 2≤2 \leq m * n ≤105\leq 10^5

  • 1≤1 \leq grid[i][j] ≤105\leq 10^5