picture is a rectangular grid of dark ("B") and light ("W") cells, and you also get a number need.
A dark pixel in row r and column c counts when both of these hold:
- row r and column c each contain exactly need dark pixels;
- every row that has a dark pixel in column c is identical to row r.
Return the number of pixels that count.picture=[["B", "W", "B"], ["B", "W", "B"], ["W", "B", "W"]], need=2 → 4
Rows 0 and 1 are identical with 2 dark pixels each, and columns 0 and 2 also hold exactly 2. All four pixels in those rows count. Pixel (2, 1) has only one dark pixel in its row.
picture=[["B", "B"], ["B", "W"]], need=2 → 0
For (0, 0) the counts match, but rows 0 and 1 differ. Column 1 and row 1 each hold only one dark pixel.
"B" or "W"picture=[["B", "W", "B"], ["B", "W", "B"], ["W", "B", "W"]], need=2
4
Run checks the first 3 tests in your browser. Submit checks all 93 tests on the server, hidden ones included.