nums 의 인자들을 음수로 변환한 값을 가진 리스트를 선언한다.heapify()를 통해 값이 들어 있는 리스트를 힙으로 변환한다.import heapq
class Solution:
def findKthLargest(self, nums: List[int], k: int) -> int:
heap = [-n for n in nums]
heapq.heapify(heap)
for _ in range(k):
findKth = -1 * heapq.heappop(heap)
return findKth