"Your algorithm should run in O(n) time and uses constant space."
Is a constant space solution without modifying the original array?
Here's my python solution with Bitwise operation
def firstMissingPositive(self, nums):
has = 0
for num in nums:
if num > 0:
has |= 1 << num
for i in range(1,len(nums) + 1):
has >>= 1
if has % 2 == 0:
return len(nums) + 1
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.