1-liner Python

  • 8

    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))

  • 0

    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"

  • 0

    Very concise and still O(mn) like the other solutions.

  • 0
    This post is deleted!

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.