Longest Run of Ones
In binary data, 1 often means a successful event, such as an active day or a passed check. Given a list nums containing only 0 and 1, find the longest continuous run of 1s. Return the length of that run.
Примеры
Ввод
[1, 1, 0, 1, 1, 1]Вывод
3Ввод
[1, 0, 1, 1, 0, 1]Вывод
2Ввод
[0, 0, 0]Вывод
0Нужно реализовать
def find_max_consecutive_ones(nums: list[int]) -> int:
Теги
arraysliding-window
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
[1,1,0,1,1,1]Expected
32
Input
[1,0,1,1,0,1]Expected
23
Input
[0,0,0]Expected
04
Input
[1,1,1,1]Expected
45
Input
[1]Expected
16
Input
[1,1,0]Expected
2Focus radio
Paused · SomaFM · Fluid