blob: 899fdf8dbf4e8cd05c7cbbdea39f8fdec9fae45b (
plain)
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
27
28
29
30
31
32
33
34
|
#!/usr/bin/env python3
import sys
def consecutive_ones(ints: list) -> int:
"""
Function to find the maximum number of consecutive 1s in a binary array.
:param ints: List of integers (0s and 1s)
:return: Maximum count of consecutive 1s
"""
max_count = 0
current_count = 0
for num in ints:
if num == 1:
current_count += 1
if current_count > max_count:
max_count = current_count
else:
current_count = 0
return max_count
def main():
# Convert input into integers
array = [int(n) for n in sys.argv[1:]]
result = consecutive_ones(array)
print(result)
if __name__ == '__main__':
main()
|