Leetcode 2113 Solution

This article provides solution to leetcode question 2113 (find-the-kth-largest-integer-in-the-array)

https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array

Solution

class Solution:
    def kthLargestNumber(self, nums: List[str], k: int) -> str:
        q = []
        for num in nums:
            heapq.heappush(q, (len(num), num))

            if len(q) > k:
                heapq.heappop(q)

        return heapq.heappop(q)[1]