Runner-Up Value
Sometimes the maximum is not enough, and you need the next unique value after it. Given a list nums, return the second largest distinct number. Repeated copies of the same value do not count as different candidates. If there is no second distinct value, return None.
Примеры
Ввод
[3, 1, 4, 1, 5, 9, 2, 6]Вывод
6Ввод
[5, 5, 5]Вывод
NoneВвод
[2, 1]Вывод
1Нужно реализовать
def second_largest(nums: list[int]) -> int | None:
Теги
array
Accedi per vedere la cronologia degli invii
AccediAccedi per usare l'AI Mentor
AccediVisible tests
1
Input
[3,1,4,1,5,9,2,6]Expected
62
Input
[5,5,5]Expected
None3
Input
[2,1]Expected
14
Input
[10]Expected
None5
Input
[1,2,2,2]Expected
16
Input
[-1,-2,-3]Expected
-2Focus radio
Paused · SomaFM · Fluid