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
PostgreSQLv16

Koodin suorituksen tulos näkyy tässä

Visible tests
1
Input
[1,1,0,1,1,1]
Expected3
2
Input
[1,0,1,1,0,1]
Expected2
3
Input
[0,0,0]
Expected0
4
Input
[1,1,1,1]
Expected4
5
Input
[1]
Expected1
6
Input
[1,1,0]
Expected2
Focus radio
Paused · SomaFM · Fluid