1985. Find the Kth Largest Integer in the Array

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 1985

class Solution:
    def kthLargestNumber(self, nums: List[str], k: int) -> str:
        def cmp(a, b):
            if len(a) != len(b):
                return len(b) - len(a)
            return 1 if b > a else -1

        nums.sort(key=cmp_to_key(cmp))
        return nums[k - 1]