beams专题

Leetcode 2125. Number of Laser Beams in a Bank [Python]

计算每行的1的数量,每两层之间的连线数量就是两层1的数量的乘积。 class Solution:def numberOfBeams(self, b: List[str]) -> int:line = []for row in b:acc = 0for j in row:if j == '1':acc += 1if acc == 0:continueline.append(acc)#print(l