Skip to content

Commit 9b8dc7b

Browse files
authored
Merge pull request vJechsmayr#563 from OMEGAeNcore/LeetCode/omega
Adding Kth Largest Element in an Array Solution
2 parents 141ddf8 + 54b5a18 commit 9b8dc7b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import heapq
2+
class Solution:
3+
def findKthLargest(self, nums: List[int], k: int) -> int:
4+
heapq.heapify(nums)
5+
res = heapq.nlargest(k,nums)
6+
return res[len(res)-1]

0 commit comments

Comments
 (0)