Longest Equal Streak

Sometimes you need to find not just a frequent value, but the longest continuous stretch of the same value. Given a list nums, return the length of the longest run of consecutive elements that are equal to each other. For an empty list, return 0.

Примеры

Ввод
[1, 1, 2, 3, 3, 3, 2]
Вывод
3
Ввод
[5]
Вывод
1
Ввод
[]
Вывод
0

Нужно реализовать

def longest_run(nums: list[int]) -> int:

Теги

array
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

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