Simple Python solution beat 97% python solutions


  • 0
    C
    def findBlackPixel(self, picture, N):
            res = 0
            C = list(zip(*picture))
            for col in C:
                if col.count('B')==N:
                    BIndex = [i for i, x in enumerate(col) if x == "B"]
                    CI=0
                    for i in range(N):
                        if picture[BIndex[i]].count('B') == N:
                            CI += 1
                            Pattern = picture[BIndex[i]]
                            break           
                    for j in range(i+1,N):
                        if Pattern != picture[BIndex[j]]:
                            break
                        CI+=1
                    if CI == N:
                        res +=N
            return res
    

Log in to reply
 

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