Python short solution


  • 0
    T
    def leastBricks(self, wall):
        """
        :type wall: List[List[int]]
        :rtype: int
        """
        edgeDict = {}
        maxEdge = 0
        for row in wall:
            curLoc = 0
            for brickLen in row[:-1]:
                curLoc += brickLen
                edgeDict[curLoc] = edgeDict[curLoc] + 1 if curLoc in edgeDict else 1
                maxEdge = max(maxEdge, edgeDict[curLoc])
        return len(wall) - maxEdge

Log in to reply
 

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