Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

class Solution: # @param {integer[]} nums # @param {integer} k # @return {integer} def findKthLargest(self, nums, k): return heapq.nlargest(k, nums)[-1]

Seems not the fastest one... Any better solution?

Thanks!

This is 12ms faster

import heapq class Solution: # @param {integer[]} nums # @param {integer} k # @return {integer} def findKthLargest(self, nums, k): heap=[] for i in nums: heapq.heappush(heap,-i) for i in range(k): res=-heapq.heappop(heap) return res

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.