InterviewBit Academy is now Scaler!
Learn Tech Skills from Scratch @ Scaler EDGE

First Missing Integer

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


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
Asked In:


Click here to start solving coding interview questions