Find the Lone Value
Imagine a set of cards where almost every card has a matching pair, but one card is alone. In the list nums, every number appears exactly twice except for one. Find and return that single number; your solution should run in linear time and use only constant extra space.
Примеры
Ввод
[2, 2, 1]Вывод
1Ввод
[4, 1, 2, 1, 2]Вывод
4Ввод
[1]Вывод
1Нужно реализовать
def single_number(nums):
Теги
arraymath
Prijavi se da vidiš povijest predaja
PrijavaPrijavi se da koristiš AI mentora
PrijavaVisible tests
1
Input
[2,2,1]Expected
12
Input
[4,1,2,1,2]Expected
43
Input
[1]Expected
14
Input
[7,3,3,7,9]Expected
95
Input
[-1,-1,5]Expected
56
Input
[0,0,6]Expected
6Focus radio
Paused · SomaFM · Fluid