Lonely Pixel II
Given a picture consisting of black and white pixels, and a positive integer N, find the number of black pixels located at some specific rowRand columnCthat align with all the following rules:
Row R and column C both contain exactly N black pixels.
For all rows that have a black pixel at column C, they should be exactly the same as row R
The picture is represented by a 2D char array consisting of 'B' and 'W', which means black and white pixels respectively.
Example:
Note:
The range of width and height of the input 2D array is [1,200].
分析
zip(*picture)遍历纵行
纵行B总数有N的 row Index push入 数组colb
再行数遍历,有N个B的行,join变成str入rowstr的set, 同时记录共有几个这样的行。
同时满足cnt++ 结果是cnt*N
Last updated