Skip to content

Commit ceb0b45

Browse files
authored
Create 0554-Brick-Wall.py
Create the Python solution as the same solution in the YouTube video "https://www.youtube.com/watch?v=Kkmv2h48ekw"
1 parent 0b13351 commit ceb0b45

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

python/0554-Brick-Wall.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)