#C5611. Smallest Missing Positive Integer

    ID: 49280 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

You are given an array of integers. Your task is to find the smallest positive integer that does not appear in the array. In other words, determine the value of

$$ \min\{ k \in \mathbb{N}^+ : k \notin nums \} $$

An efficient solution with an expected time complexity of \(O(n)\) is required.

inputFormat

The input begins with an integer \(T\) on the first line, representing the number of test cases. For each test case, the first line contains an integer \(n\) which is the number of elements in the array. The second line contains \(n\) space-separated integers.

outputFormat

For each test case, output the smallest missing positive integer on a separate line.

## sample
2
3
1 2 0
4
3 4 -1 1
3

2

</p>