Does calling the sort() method count as cheat?

  • 0

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

        def findKthLargest(self, nums, k):
            return nums[k - 1]

  • 0

    Here it's just a practice, whatever you do will be fine.

    But if you encountered this in an interview, you know what the interviewer expect right?

Log in to reply

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