# First Missing Positive

Posted: 11 Sep, 2020

Difficulty: Moderate

#### You are given an array 'ARR' of integers of length N. Your task is to 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 have negative numbers as well.

#### For example, the input [3, 4, -1, 1] should give output 2 because it is the smallest positive number that is missing in the input array.

##### Input format:

```
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of each test case contains a positive integer N which represents the length of the array.
The second line of each test case contains N integers representing the elements of the array 'ARR'.
```

##### Output Format :

```
For each test case, print a single integer denoting the minimum positive integer that is missing from the given input array.
Th output of each test case will be printed in a separate line.
```

##### Note:

```
You do not need to print anything. It has already been taken care of. Just implement the given function.
```

##### Constraint :

```
1 <= T <= 10
1 <= N <= 10^5
-10^5 <= ARR[i] <= 10^5
Time Limit: 1 sec
```

SIMILAR PROBLEMS

Best time to buy and sell stock

Posted: 2 Sep, 2022

Difficulty: Moderate

Best time to buy and sell stock II

Posted: 5 Sep, 2022

Difficulty: Moderate

LRU Cache

Posted: 10 Sep, 2022

Difficulty: Moderate

Array Rotation

Posted: 21 Oct, 2022

Difficulty: Easy

Find The Single Element

Posted: 30 Oct, 2022

Difficulty: Easy