Does calling the sort() method count as cheat?


  • 0
    C

    Simply sort the array and return k - 1 element. 2 lines AC.

        def findKthLargest(self, nums, k):
            nums.sort(reverse=True)
            return nums[k - 1]
    

Log in to reply
 

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