Elegant python solution


  • 0
    V
    class Solution(object):
        def leastBricks(self, wall):
            count_map = {}
            for row in wall:
                sum = 0
                for i in range(len(row)-1):
                    sum += row[i]
                    count_map[sum] = count_map.get(sum, 0) + 1
            return len(wall) - (max(count_map.values()) if count_map.values() else 0)
    

Log in to reply
 

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