Longest Equal Run
In a stream of bytes, it can be useful to notice a long consecutive repeat of the same value. Given a list data, return the length of the longest contiguous run of equal elements. Count only values that appear next to each other, not the total number of equal bytes in the whole list. For an empty list, return 0.
Примеры
Ввод
[1, 1, 1, 2, 3, 3]Вывод
3Ввод
[144, 144, 144, 144]Вывод
4Ввод
[]Вывод
0Нужно реализовать
def longest_run(data):
Теги
arraylists
Melde dich an, um den Einreichungsverlauf zu sehen
AnmeldenMelde dich an, um den KI-Mentor zu nutzen
AnmeldenVisible tests
1
Input
[1,1,1,2,3,3]Expected
32
Input
[144,144,144,144]Expected
43
Input
[]Expected
04
Input
[5]Expected
15
Input
[1,2,1,2,1]Expected
16
Input
[7,7,0,0,0,0,9]Expected
4Focus radio
Paused · SomaFM · Fluid