Brick Wall LeetCode solution in Python
1class Solution:2def leastBricks(self, wall: List[List[int]]) -> int:3m = len(wall)4ctr = {}5res = m6for i in range(m):7n = len(wall[i])8curr = 09for j in range(n - 1):10curr += wall[i][j]11x = ctr.get(curr, m) - 112ctr[curr] = x13res = min(res, x)14return res