1. You are given an array of N elements.
2. You are also given a number K.
3. You have to find the Kth largest element in an array.
4. For example:
Input: arr = [3,2,1,5,6,4] and K = 2
Output: 5
5. display is a utility function, feel free to use it for debugging purposes.
6. main takes input from the users and creates the array.
7. This is a functional problem.
8. You have to complete the findKthLargest function. It takes as input an array and K. It should return the Kth largest element in the array.
9. Don't change the code of main and display.
Input Format
First line takes input N, the length of the array. Second line takes input N space separated numbers representing the elements of the array. Third line takes input K. Input is handled for you.
Output Format
Kth largest element in the array. Output is handled for you.
Constraints
1 <= N <= 30000
Notice
Try First, Check Solution later
1. You should first read the question and watch the question video.2. Think of a solution approach, then try and submit the question on editor tab.3. We strongly advise you to watch the solution video for prescribed approach.Example
Input
6 3 2 1 5 6 4 2
Output
5