Hottest Value
In a cache, a "hot" value is the one that gets used most often. The function most_frequent receives a non-empty list items and returns the element with the highest number of occurrences. If several elements occur equally often, return the one that reaches that maximum count first.
Примеры
Ввод
[1, 2, 2, 3, 3, 3]Вывод
3Ввод
[5]Вывод
5Ввод
["a", "b", "a", "b", "a"]Вывод
"a"Нужно реализовать
def most_frequent(items):
Теги
arraylistsdicthashmap
Log in om je inzendingsgeschiedenis te zien
InloggenLog in om de AI-mentor te gebruiken
InloggenVisible tests
1
Input
[1,2,2,3,3,3]Expected
32
Input
[5]Expected
53
Input
["a","b","a","b","a"]Expected
"a"4
Input
[1,1,2,2]Expected
15
Input
[7,7,7,1,1,1,7]Expected
76
Input
[2,3,3,4,4,4]Expected
4Focus radio
Paused · SomaFM · Fluid