Back to exercises

Kth Largest Element in an Array

Push each number into a heap, trim the heap whenever it grows beyond size k, and the root will end up as the kth largest value.

Coding Exercises Medium O(n log k)

Kth Largest Element in an Array

Push each number into a heap, trim the heap whenever it grows beyond size k, and the root will end up as the kth largest value.

Return the kth largest element from an unsorted list.