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 sorted order, not the kth distinct element.

Constraints

  • 1 <= k <= nums.length <= 10^5
  • -10^4 <= nums[i] <= 10^4
Auto-saved · 3 lines
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
Console

Click Run to execute sample tests.