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.
Tagged with heap
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.
Build a frequency map, then select the top k items by count using a heap-based helper or a bucket sort approach.
Return the k most frequent values from an integer list.