Skip to content

Latest commit

 

History

History
19 lines (12 loc) · 457 Bytes

README.md

File metadata and controls

19 lines (12 loc) · 457 Bytes

First missing positive integer

This problem was asked by Stripe.

Description

Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.

You can modify the input array in-place.

Examples

Input: [3, 4, -1, 1]
Output: 2

Input: [1, 2, 0]
Output: 3