bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
MediumHeap / Priority QueueLC 215

Kth Largest Element In An Array

Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in the sorted order, not the kth distinct element. You must solve it in O(n) time complexity.

Asked at 29 companies
AdobeAirbnbAlibaba
Hints
  • 1.Think about what data structure fits Kth Largest Element In An Array
  • 2.Consider the brute force complexity and how to optimize
  • 3.Can you trade space for time?
LeetCodeNeetCode