First Missing Integer

Given an unsorted integer array, find the first missing positive integer.

Example:

Given [1,2,0] return 3,

[3,4,-1,1] return 2,

[-8, -7, -6] returns 1

Your algorithm should run in O(n) time and use constant space.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving First Missing Integer on Interview Code Editor
Sign Up
to access hints and editorial solutions for First Missing Integer
13566 successful submissions.
Asked In:
  • Model N
  • InMobi
Click here to start solving coding interview questions