Python simple


  • 0
    class Solution(object):
        def findLonelyPixel(self, picture):
            """
            :type picture: List[List[str]]
            :rtype: int
            """
            r_no = len(picture)
            c_no = len(picture[0])
            search_r = [[i, i.index('B')] for i in picture if i.count('B')==1]
            seen_c = set()
            count = 0
            for i in search_r:
                if i[1] in seen_c: continue
                conflict_r = filter(lambda x:x[i[1]]=='B', picture)
                conflict_r_no = len(conflict_r)
                seen_c.add(i[1])
                if conflict_r_no == 1:
                    count += 1
            return count
    

Log in to reply
 

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