Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

"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

class Solution: 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 i return len(nums) + 1

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.