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
Prihláste sa, aby ste videli históriu odoslaní
Prihlásiť saPrihláste sa, aby ste mohli používať AI mentora
Prihlásiť saVisible tests
1
Input
[1,1,2,3,3,3,2]Expected
32
Input
[5]Expected
13
Input
[]Expected
04
Input
[1,2,3,4]Expected
15
Input
[7,7,7,7]Expected
46
Input
[1,1,2]Expected
2Focus radio
Paused · SomaFM · Fluid