| Topic | Difficulty | Companies |
|---|---|---|
| Heap and Priority Queue | MEDIUM | Google Amazon Facebook |
Given an unsorted array arr of size n and an integer k, write a program to find the k’th largest element in the given array.
Problem Note
Example 1
Input: arr[] = [6, 5, 1, 8, 9] and k = 2
Output: 8
Explanation: 8 is the 2nd largest element in the array.
Example 2
Input: arr[] = [1, 2, 3, 4, 5] and k = 2
Output: 4
Explanation: 4 is the 2nd largest element in the array.