#K94287. Finding the Smallest Missing Non-negative Integer
Finding the Smallest Missing Non-negative Integer
Finding the Smallest Missing Non-negative Integer
Given a list of integers, your task is to find the smallest non-negative integer (i.e. an integer \(x \ge 0\)) that does not appear in the list.
The input consists of multiple test cases. For each test case, you will be given an integer \(N\) representing the number of elements in the list, followed by \(N\) space-separated integers. For each test case, output the smallest missing non-negative integer on a new line.
For example, if the list is [1, 2, 0, 4, 5], the smallest missing non-negative integer is 3.
inputFormat
The first line contains an integer \(T\), the number of test cases.
For each test case, the first line contains an integer \(N\) (the number of integers in the list). The following line contains \(N\) space-separated integers.
outputFormat
For each test case, output a single line with the smallest missing non-negative integer.
## sample3
5
1 2 0 4 5
6
-1 -2 0 -4 -5 -6
8
0 1 3 4 5 6 7 8
3
1
2
</p>