Given an array of positive integers, Your task is to find maximum possible value K such that the array has at-least K elements that are greater than or equal to K.
Note: The array is unsorted and may contain duplicate values.
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow.
The first line of each test case contains a positve integer N, denoting the length of the array A[ ].
The second line of each test case contains a N space seprated positve integers, denoting the elements of the array A[ ].
Print the maximum possible value K.
1 <= T <= 100
2 <= N <=30
0 <= A[ ] <= 100
2 3 4 5 6 7
1 2 3 4
In the first test case for the arrray [2, 3, 4, 5, 6, 7] 4 elements [4, 5, 6, 7] which are greater than equal to 4 hence 4 is output .
In the second test case for the array [1,2,3,4] there are 3 elements [2, 3, 4] which are greater than equal to 2 hence 2 is output .
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.