class Solution: def singleNumber(self, nums: List[int]) -> int: return functools.reduce(lambda acc, v: acc ^ v, nums) Complexity Time: O(n) Space: O(1) — But O(n) in this functional approach