We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b13351 commit ceb0b45Copy full SHA for ceb0b45
python/0554-Brick-Wall.py
@@ -0,0 +1,11 @@
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
0 commit comments