Practice Maximum Rows Covered by Columns
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Rows Covered by Columns
Problem Statement
You are given an m x n binary matrix matrix and an integer numSelect. Your goal is to select exactly numSelect distinct columns from matrix such that you cover as many rows as possible. A row is considered covered if all the 1's in that row are also part of a column that you have selected. If a row does not have any 1s, it is also considered covered. More formally, let us consider selected = {c1, c2, ...., cnumSelect} as the set of columns selected by you. A row i is covered by selected if: Return the maximum number of rows that can be covered by a set of numSelect columns.
Source: Maximum Rows Covered by Columns on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
matrix = [[0,0,0],[1,0,1],[0,1,1],[0,0,1]], numSelect = 2
3
# Example 2
matrix = [[1],[0]], numSelect = 1
2
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Rows Covered by Columns.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.