Find the Kth Largest Integer in the Array

You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.

Return the string that represents the k^th largest integer in nums.

Note: Duplicate numbers should be counted distinctly. For example, if nums is ["1", "2", "2"], "2" is the first largest integer, "2" is the second-largest integer, and "1" is the third-largest integer.

Example 1
Inputnums = ["3","6","7","10"], k = 4
Output"3"
The numbers in nums sorted in non-decreasing order are ["3", "6", "7", "10"], so the 4^th largest integer is "3".
Example 2
Inputnums = ["2","21","12","1"], k = 3
Output"2"
The numbers in nums sorted in non-decreasing order are ["1", "2", "12", "21"], so the 3^rd largest integer is "2".

Constraints

  • 1 <= k <= nums.length <= 10^4
  • 1 <= nums[i].length <= 100
  • nums[i] consists of only digits.
  • nums[i] will not have any leading zeros.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate