Largest List Value
Finding the maximum is useful everywhere: the highest price, the best score, or the largest number of orders. Write a function max_of_list that returns the greatest element of the non-empty list nums. Remember that among negative numbers, the maximum is the one closest to zero.
Примеры
Ввод
[1, 2, 3]Вывод
3Ввод
[5, 4, 3, 2, 1]Вывод
5Ввод
[-5, -2, -9]Вывод
-2Нужно реализовать
def max_of_list(nums: list[int]) -> int:
Теги
arraylists
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
[1,2,3]Expected
32
Input
[5,4,3,2,1]Expected
53
Input
[-5,-2,-9]Expected
-24
Input
[42]Expected
425
Input
[7,7,7]Expected
76
Input
[3,100,2,99]Expected
100Focus radio
Paused · SomaFM · Fluid