#K61912. Smallest Missing Positive Integer

    ID: 31415 Type: Default 1000ms 256MiB

Smallest Missing Positive Integer

Smallest Missing Positive Integer

You are given several test cases. In each test case, you are given a list of integers. Your task is to find the smallest positive integer (greater than 0) that does not appear in the list.

Input Format: The input begins with an integer T denoting the number of test cases. For each test case, the first line contains an integer n, the number of elements in the list. The following line contains n space-separated integers.

Output Format: For each test case, output a single line containing the smallest positive integer that is missing from the list. Each answer should be output on a new line.

Note: The input is read from standard input and the output is written to standard output.

inputFormat

The first line of input contains a single integer T representing the number of test cases. For each test case:

  • The first line contains an integer n, the number of elements in the list.
  • The second line contains n space-separated integers representing the list.

Input is provided via standard input.

outputFormat

For each test case, output the smallest missing positive integer on a separate line. Output is written to standard output.

## sample
3
5
2 3 7 6 8
4
-1 -3 4 2
3
1 2 3
1

1 4

</p>