aboutsummaryrefslogtreecommitdiffstats
path: root/2
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-03 02:09:44 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-03 02:09:44 +0000
commite2acf8a8fc852826cf603b0ecfd83d4f021a43d0 (patch)
tree653f7e752b3c37a0e0b1e584456e8c40c1a0e97b /2
parent2610 (diff)
downloadleetcode-e2acf8a8fc852826cf603b0ecfd83d4f021a43d0.tar.gz
leetcode-e2acf8a8fc852826cf603b0ecfd83d4f021a43d0.zip
2125
Diffstat (limited to '')
-rwxr-xr-x2610/2125/main.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/2610/2125/main.py b/2610/2125/main.py
new file mode 100755
index 0000000..da45c29
--- /dev/null
+++ b/2610/2125/main.py
@@ -0,0 +1,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()