题目链接:https://leetcode.cn/problems/kth-largest-element-in-an-array/
难度:中等
描述:
给定整数数组 nums
和整数 k
,请返回数组中第 **k**
个最大的元素。
请注意,你需要找的是数组排序后的第 k
个最大的元素,而不是第 k
个不同的元素。
题解
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
nums.sort()
return nums[-k]
TODO: Partition
TODO: heap (big endian and small endian)