AC Python Solution


  • 0
    S
    def findLonelyPixel(self, picture):
        result = 0
        row = [0 for i in range(len(picture))]
        col = [0 for i in range(len(picture[0]))]
        
        for m in range(len(picture)):
            for n in range(len(picture[0])):
                if picture[m][n] == 'B':
                    row[m]+= 1 
                    col[n]+= 1 
        
        for m in range(len(picture)):
            for n in range(len(picture[0])):
                if picture[m][n] == 'B' and row[m] == 1 and col[n] == 1:result+=1
        return result

Log in to reply
 

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