java.lang.Object
g1701_1800.s1727_largest_submatrix_with_rearrangements.Solution

public class Solution extends Object
1727 - Largest Submatrix With Rearrangements.<p>Medium</p> <p>You are given a binary matrix <code>matrix</code> of size <code>m x n</code>, and you are allowed to rearrange the <strong>columns</strong> of the <code>matrix</code> in any order.</p> <p>Return <em>the area of the largest submatrix within</em> <code>matrix</code> <em>where <strong>every</strong> element of the submatrix is</em> <code>1</code> <em>after reordering the columns optimally.</em></p> <p><strong>Example 1:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/12/29/screenshot-2020-12-30-at-40536-pm.png" alt="" /></p> <p><strong>Input:</strong> matrix = [[0,0,1],[1,1,1],[1,0,1]]</p> <p><strong>Output:</strong> 4</p> <p><strong>Explanation:</strong> You can rearrange the columns as shown above. The largest submatrix of 1s, in bold, has an area of 4.</p> <p><strong>Example 2:</strong></p> <p><img src="https://assets.leetcode.com/uploads/2020/12/29/screenshot-2020-12-30-at-40852-pm.png" alt="" /></p> <p><strong>Input:</strong> matrix = [[1,0,1,0,1]]</p> <p><strong>Output:</strong> 3</p> <p><strong>Explanation:</strong> You can rearrange the columns as shown above. The largest submatrix of 1s, in bold, has an area of 3.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> matrix = [[1,1,0],[1,0,1]]</p> <p><strong>Output:</strong> 2</p> <p><strong>Explanation:</strong> Notice that you must rearrange entire columns, and there is no way to make a submatrix of 1s larger than an area of 2.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>m == matrix.length</code></li> <li><code>n == matrix[i].length</code></li> <li><code>1 <= m * n <= 10<sup>5</sup></code></li> <li><code>matrix[i][j]</code> is either <code>0</code> or <code>1</code>.</li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • largestSubmatrix

      public int largestSubmatrix(int[][] matrix)