Practice Largest Submatrix With Rearrangements
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order. Return the area of the largest submatrix within matrix where every element of the submatrix is 1 after reordering the columns optimally.
Source: Largest Submatrix With Rearrangements on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
matrix = [[0,0,1],[1,1,1],[1,0,1]]
Output
4
# Example 2
Input
matrix = [[1,0,1,0,1]]
Output
3
# Example 3
Input
matrix = [[1,1,0],[1,0,1]]
Output
2
Constraints
m == matrix.length
n == matrix[i].length
1 <= m * n <= 10^5
matrix[i][j] is either 0 or 1.
Related LeetCode Problems
Practice more problems similar to Largest Submatrix With Rearrangements.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.