FastPrepFirst Missing Positive
Problems/First Missing Positive

First Missing Positive

Microsoft logoMicrosoft● HardFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report from a Microsoft Data Scientist PhD intern names the First Missing Positive task, and another source backs it up. Our version follows the usual rule of linear time and constant extra space. We chose the function signature and the limits. Our version is about 95% the same as the reported question.

Given an unsorted integer array nums, return the smallest positive integer that does not appear in the array.

Your algorithm must run in O(n) time and use O(1) extra space, excluding the input array.

Function

firstMissingPositive(nums: int[]) → int

Examples

Example 1

nums = [1,2,0]return = 3

The positive values 1 and 2 are present, so 3 is the first missing positive.

Example 2

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

The value 1 is present but 2 is absent.

Example 3

nums = [7,8,9,11,12]return = 1

No value 1 appears.

Constraints

  • 1 <= nums.length <= 100000.
  • -2^31 <= nums[i] <= 2^31 - 1.

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Max Points on a LineUber · PHONE SCREENUber interview questions
  • Process Shopping Records, Promotions, and Display OrderInstacart · PHONE SCREEN · ONSITE INTERVIEWInstacart interview questions
  • Randomized String MultisetLinkedIn · PHONE SCREENLinkedIn interview questions
  • Optimal Account BalancingPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
  • Detect Security Attacks from Network LogsFireworks AI · PHONE SCREEN
  • Longest Content Window with Bounded LabelsAmazon · PHONE SCREEN
  • First Missing PositiveGoogle · PHONE SCREENGoogle interview questions
  • Smallest Range Covering Elements from K ListsSnap Inc. · PHONE SCREENSnap Inc. interview questions
  • Lab and Consultation Appointment MatchingAssort Health · PHONE SCREENAssort Health interview questions
  • Chatter Message WindowReddit · PHONE SCREENReddit interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int firstMissingPositive(int[] nums) {
      // write your code here
    }
}
Checking account…