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
Entre para ver seu histórico de envios
EntrarEntre para usar o AI Mentor
EntrarVisible tests
1
Input
[1,2,3,4,5]Expected
42
Input
[7,7,7]Expected
-13
Input
[]Expected
-14
Input
[-4,-2,-8]Expected
-25
Input
[10]Expected
106
Input
[1,3,6,6,5]Expected
6Focus radio
Paused · SomaFM · Fluid