Find the Kth Largest Integer in the Array - Problem
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 kth 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.
Input & Output
Example 1 — Basic Case
$
Input:
nums = ["3","6","7","10"], k = 4
›
Output:
"3"
💡 Note:
Sorted in descending order: ["10","7","6","3"]. The 4th largest is "3".
Example 2 — With Duplicates
$
Input:
nums = ["2","21","12","1"], k = 3
›
Output:
"2"
💡 Note:
Sorted: ["21","12","2","1"]. The 3rd largest is "2".
Example 3 — Large Numbers
$
Input:
nums = ["1","2","2"], k = 2
›
Output:
"2"
💡 Note:
Sorted: ["2","2","1"]. Both "2"s are counted distinctly, so 2nd largest is "2".
Constraints
- 1 ≤ k ≤ nums.length ≤ 104
- 1 ≤ nums[i].length ≤ 100
- nums[i] consists of only digits
- nums[i] will not have any leading zeros
Visualization
Tap to expand
Understanding the Visualization
1
Input
Array of string numbers and target k
2
Sort
Sort strings by numeric value (not lexicographically)
3
Output
Return kth element from sorted array
Key Takeaway
🎯 Key Insight: String numbers need special comparison - longer strings are larger numbers, not lexicographic ordering
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code