def firstMissingPositive(self,nums):

```
if not nums:
return 1
n=max(nums)
res=0
for each in nums:
if each>0:
val=1<<each
if (res&val)==0:
res^=val
for each in range(1,n+1):
val=1<<each
if (val&res)==0:
return each
return n+1
```