(self, wall: List[List[int]])
| 1 | class Solution: |
| 2 | def leastBricks(self, wall: List[List[int]]) -> int: |
| 3 | countGap = { 0 : 0 } # { Position : Gap count } |
| 4 | |
| 5 | for r in wall: |
| 6 | total = 0 # Position |
| 7 | for b in r[:-1]: |
| 8 | total += b |
| 9 | countGap[total] = 1 + countGap.get(total, 0) |
| 10 | |
| 11 | return len(wall) - max(countGap.values()) # Total number of rows - Max gap |