Kth Largest Element in an Array
Medium · Heap & Priority Queue · about 15 minutes
Asked at Meta, Amazon, Microsoft, LinkedIn, Quora.
Imagine nums sorted from largest to smallest and return the value at position k (counting from 1). Repeated values each take a position. See whether you can avoid sorting the whole array.