given an array of integers every element appears twice except for one find that single one note this also works for finding a number occurring odd number of times where all the other numbers appear even number of times note your algorithm should have a linear runtime complexity could you implement it without using extra memory returns single number if found else if all numbers appear twice returns 0 type nums listint rtype int returns single number if found else if all numbers appear twice returns 0 type nums list int rtype int
def single_number(nums):
    
    i = 0
    for num in nums:
        i ^= num
    return i