Answer: Sony India Hiring Challenge | Kth Largest Element in an Array | On-Campus OA (20
Answer · Posted Jun 2026
Approach Maintain a Min Heap (Priority Queue) of size k. Traverse the array: Insert each element into the heap. If the heap size exceeds k, remove the smallest element. After processing all elements, the heap contains the k largest elements. The top of the heap is the kth largest element. Strategy Create a Min Heap. Traverse every element in the array. Insert the current element into the heap. If heap size becomes greater than k, remove the smallest element. Return ...
The full answer & interview discussion are available to premium members.
Log in Create a free account