FastPrepFirst Missing Positive
Problems/First Missing Positive

First Missing Positive

Google logoGoogle● HardINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: An anonymous report from a Google Summer 2027 internship interview describes First Missing Positive. It starts with a hash set, then optimizes in place by placing each number in its own slot in a cycle. Our version keeps the reported goal of O(n) time and O(1) extra space. We added the function signature, the standard examples, and the integer limits. Our version is about 90% 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 Google Phone Screen questions

  • Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
  • Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
  • Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
  • Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
  • Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 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
  • 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
  • Optimal Account BalancingSalesforce · PHONE SCREENSalesforce interview questions

Interview reports that mention this question

  • Google Intern Team Matching: 14 Experiences (Part 4 of 8)

Google interview experiences

  • Google interviews · November 2026
  • Google Software Engineer Onsite Questions: 10 Experiences
  • Google OA: What It Tests (2026)
  • Google L4 SWE Phone Screen: 1 Experience
  • Google ML Engineering Manager Onsite: 1 Experience
All Google interview questionsSee Google hiring insights
Saved
class Solution {
    public int firstMissingPositive(int[] nums) {
      // write your code here
    }
}
Checking account…