```
def findDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
#toggle bits if num is found in array
bits = 0
for n in nums:
nthbit = (bits >> n) & 1
if nthbit == 0:
bits |= 1 << n
else:
return n
return -1
```