top of page

Looking to master object-oriented and system design for tech interviews or career growth?

  • Improve your system design and machine coding skills.

  • Study with our helpful resources.

  • Prepare for technical interviews and advance your career.

**We're in beta mode and would love to hear your feedback.

Writer's pictureilluminati

First Missing Integer Interviewbit Solution


Problem Description:

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.

Solution:

Method 1:

Time Complexity: O(N) 
Space Complexity: O(N)


Method 2:

Time Complexity: O(NlogN)
Space Complexity: O(1)


Method 3:

Time Complexity: O(N)
Space Complexity: O(1)

2 תגובות


Chicku Singh
Chicku Singh
27 במאי 2021

It looks in the code given above , first approach missed space constraints and second approach missed time constraint. ( As per InterviewBit problem statement)

לייק
illuminati
illuminati
29 במאי 2021
בתשובה לפוסט של

Thank you @Chicku Singh for pointing that out. We have fixed the solution according to the original problem statement.

לייק
bottom of page