Question
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.
https://leetcode.com/problems/kth-largest-element-in-an-array/
- Solution1
1 | class Solution { |
Complexity:
Time complexity: O(nlog(k))
Space complexity: O(k)