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
PostgreSQLv16

Hawn jidher ir-riżultat tat-tħaddim tal-kodiċi

Visible tests
1
Input
[2,2,1]
Expected1
2
Input
[4,1,2,1,2]
Expected4
3
Input
[1]
Expected1
4
Input
[7,3,3,7,9]
Expected9
5
Input
[-1,-1,5]
Expected5
6
Input
[0,0,6]
Expected6
Focus radio
Paused · SomaFM · Fluid