grid of zeros and ones and a number picks. Mark exactly picks distinct columns.
A row is covered when every one in it sits in a marked column. A row with no ones is always covered.
Return the largest number of rows you can cover by marking picks columns.grid=[[1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 0]], picks=1 → 2
Marking column 0 covers rows 0 and 3 (row 3 has no ones at all). Column 1 also covers two rows, column 2 only row 3. No single column covers more than two rows.
grid=[[0, 1], [1, 1], [1, 0]], picks=2 → 3
Both columns are marked, so every row is covered and the answer is 3.
grid.length ≤ 12grid[i].length ≤ 12, all rows have the same lengthgrid[i][j] is 0 or 1picks ≤ grid[0].lengthgrid=[[1, 0, 0], [0, 1, 0], [1, 1, 0], [0, 0, 0]], picks=1
2
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.