Leetcode 554 Solution
This article provides solution to leetcode question 554 (brick-wall)
Access this page by simply typing in "lcs 554" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
https://leetcode.com/problems/brick-wall
Solution
class Solution:
def leastBricks(self, walls: List[List[int]]) -> int:
m = collections.defaultdict(int)
for wall in walls:
cur = 0
for i in range(0, len(wall) - 1):
cur += wall[i]
m[cur] += 1
return len(walls) - (max(m.values()) if m else 0)