Python AC Solution


  • 1
    S
    class Solution(object):
        def findLonelyPixel(self, picture):
            """
            :type picture: List[List[str]]
            :rtype: int
            """
            if not picture:
                return 0
            
            bpos = []
            for row in picture:
                idx = [i for i in range(len(row)) if row[i] == 'B']
                bpos.append(idx)
            cnt = 0
    
            bposFlat = sum(bpos, [])
            
            for row in bpos:
                if len(row) == 1 and bposFlat.count(row[0]) == 1:
                    cnt += 1
            return cnt
    

Log in to reply
 

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