Given an array arr of non-negative integers of size N, the task is to find an integer H such that at least K integers in the array are greater or equal to K.
Input: arr = [3, 0, 6, 1, 5]
Explanation: There are 3 number greater than or equal to 3 in the array i.e. 3, 6 and 5.
Input: arr = [9, 10, 7, 5, 0, 10, 2, 0]
Approach: Using Hashing
The number integer K can not be greater than the size of arr. So, maintain the frequency of each element in a frequency array(hash table). Then traverse the frequency array from the end and return the first index that matches the condition.
Below is the implementation of the above approach.
Time Complexity O(N)
Space Complexity O(N)
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Find element in a sorted array whose frequency is greater than or equal to n/2.
- Minimum number greater than the maximum of array which cannot be formed using the numbers in the array
- Find the number of elements greater than k in a sorted array
- Numbers with prime frequencies greater than or equal to k
- Find the number of operations required to make all array elements Equal
- Sum of elements in an array with frequencies greater than or equal to that element
- Adding elements of an array until every element becomes greater than or equal to k
- Find Kth number from sorted array formed by multiplying any two numbers in the array
- Find the minimum number of operations required to make all array elements equal
- Noble integers in an array (count of greater elements is equal to value)
- Number of non-decreasing sub-arrays of length greater than or equal to K
- Fill the missing numbers in the array of N natural numbers such that arr[i] not equal to i
- Find the number of different numbers in the array after applying the given operation q times
- Find minimum value to assign all array elements so that array product becomes greater
- Find K such that changing all elements of the Array greater than K to K will make array sum N
- Find next Smaller of next Greater in an array
- Find the next greater element in a Circular Array
- Find closest greater value for every element in array
- Make all numbers of an array equal
- Find next greater number with same set of digits
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.