Clear Python Solution

  • 6
    class Solution(object):
        def leastBricks(self, wall):
            :type wall: List[List[int]]
            :rtype: int
            d = collections.defaultdict(int)
            for line in wall:
                i = 0
                for brick in line[:-1]:
                    i += brick
                    d[i] += 1
            # print len(wall), d
            return len(wall)-max(d.values()+[0])

Log in to reply

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