blob: da45c2960e807c66cb26c9533b9bdee2507105fd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/usr/bin/env python
import typing
class Solution:
def numberOfBeams(self, bank: typing.List[str]) -> int:
row_count = 0
result = 0
for row in bank:
count = row.count("1")
if count != 0:
result += row_count * count
row_count = row.count("1")
return result
def main():
solution = Solution()
print(solution.numberOfBeams(["011001", "000000", "010100", "00100"]))
print(solution.numberOfBeams(["000", "111", "000"]))
if __name__ == "__main__":
main()
|