#C11902. Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
Find the Smallest Missing Positive Integer
You are given \(T\) test cases. In each test case, you are provided with an integer \(N\) (the number of elements in an array) followed by \(N\) space-separated integers. Your task is to find the smallest missing positive integer, i.e. the smallest integer \(x\) such that \(x > 0\) and \(x\) does not appear in the array.
Note: You must implement a solution that reads the input from stdin
and writes the output to stdout
. Each result should be output on a new line corresponding to each test case.
inputFormat
The input is given in the following format:
The first line contains an integer (T), the number of test cases. For each test case, the first line contains an integer (N) (the size of the array), followed by a line with (N) space-separated integers.
outputFormat
For each test case, output a single line containing the smallest missing positive integer.## sample
2
3
1 2 0
4
3 4 -1 1
3
2
</p>