Go through the columns, count how many have exactly one black pixel and it's in a row that also has exactly one black pixel.
def findLonelyPixel(self, picture): return sum(col.count('B') == 1 == picture[col.index('B')].count('B') for col in zip(*picture))
I am a Javaer.
And the lines number of my Python code is 30+.
YOU make me have a new view of "Life is short, you need Python"
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.