Largest Even Number

Sometimes you need to choose the best value from a list, but only among numbers that match a condition. Given a list nums, find the largest even number in it. If there are no even numbers, return -1.

Примеры

Ввод
[1, 2, 3, 4, 5]
Вывод
4
Ввод
[7, 7, 7]
Вывод
-1
Ввод
[]
Вывод
-1

Нужно реализовать

def max_even(nums: list[int]) -> int:

Теги

arraymath
PostgreSQLv16

Her vises resultatet af din kode

Visible tests
1
Input
[1,2,3,4,5]
Expected4
2
Input
[7,7,7]
Expected-1
3
Input
[]
Expected-1
4
Input
[-4,-2,-8]
Expected-2
5
Input
[10]
Expected10
6
Input
[1,3,6,6,5]
Expected6
Focus radio
Paused · SomaFM · Fluid