Google·Software Engineer·Onsite - Coding / Algorithms
- Design a class that supports inserting numbers (including duplicates) and finding the (k+1)-th largest value in the collection, where findLargest(0) returns the max. Optimize for query time over insert time.
“My first instinct was a max-heap and I said it out loud before realizing that only works if k is fixed ahead of time.”