hardArrayEnumerationMatrix 0 views
Find the Minimum Area to Cover All Ones II
You are given a 2D binary array grid.
You are given a 2D binary array grid. You need to find 3 non-overlapping rectangles having non-zero areas with horizontal and vertical sides such that all the 1's in grid lie inside these rectangles.
Return the minimum possible sum of the area of these rectangles.
Note that the rectangles are allowed to touch.
Example 1
Input: grid = [[1,0,1],[1,1,1]]
Output: 5
Example 2
Input: grid = [[1,0,1,0],[0,1,0,1]]
Output: 5
Constraints
- 1 <= grid.length, grid[i].length <= 30
- grid[i][j] is either 0 or 1.
- The input is generated such that there are at least three 1's in grid.
Hints
Companies
No companies reported yet.
Discussion
Sign in to join the discussion.
Loading discussion...
Test results
No test cases yet.