题目描述
Given an array Arr of N positive integers. Find the maximum possible value of K such that the array has at-least K elements that are greater than or equal to K.
Example 1:
Input:
N = 6
Arr[] = {2, 3, 4, 5, 6, 7}
Output: 4
Explanation: 4 elements [4, 5, 6, 7]
are greater than equal to 4.
Example 2:
Input:
N = 4
Arr[] = {1, 2, 3, 4}
Output: 2
Explanation: 3 elements [2, 3, 4] are
greater than equal to 2.
Your Task:
You don't need to read input or print anything. Your task is to complete the function findMaximumNum() which takes the array of integers arr and its size n as input parameters and returns an integer denoting the answer.
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
Constraints:
2 <= N <= 10^{5}
0 <= Arr[i] <= 10^{6}
The array is unsorted and may contain duplicate values.
输入格式
见题面
输出格式
见题面