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
PostgreSQLv16

Tutaj pojawi się wynik wykonania kodu

Visible tests
1
Input
[1,2,3]
Expected3
2
Input
[5,4,3,2,1]
Expected5
3
Input
[-5,-2,-9]
Expected-2
4
Input
[42]
Expected42
5
Input
[7,7,7]
Expected7
6
Input
[3,100,2,99]
Expected100
Focus radio
Paused · SomaFM · Fluid