Unpaired Value
In this list, almost every number appears as a pair, but one value has no matching copy. Given nums, return that single element. The solution must run in O(n) time and use O(1) extra space. Think about the xor operation, where equal numbers cancel each other out.
Примеры
Ввод
[2, 2, 1]Вывод
1Ввод
[4, 1, 2, 1, 2]Вывод
4Ввод
[1]Вывод
1Нужно реализовать
def single_number(nums: list[int]) -> int:
Теги
matharrayhashmap
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
[2,2,1]Expected
12
Input
[4,1,2,1,2]Expected
43
Input
[1]Expected
14
Input
[7,3,7,3,9]Expected
95
Input
[-1,-1,5]Expected
56
Input
[7,3]Expected
4Focus radio
Paused · SomaFM · Fluid