My 45ms Python solution


  • 0
    F

    ...
    class Solution(object):
    def findKthLargest(self, nums, k):
    """
    :type nums: List[int]
    :type k: int
    :rtype: int
    """
    nums.sort()
    return nums[-k]
    ...


  • 1
    S

    Interestingly, this O(nlogn) solution is somehow comparable to O(n) quick select solution's performance. But it will fail interview, almost for sure. LOL


Log in to reply
 

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