1985. Find the Kth Largest Integer in the Array Medium
1/**
2 * [1985] Find the Kth Largest Integer in the Array
3 *
4 * You are given an array of strings nums and an integer k. Each string in nums represents an integer without leading zeros.
5 * Return the string that represents the k^th largest integer in nums.
6 * 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.
7 *
8 * Example 1:
9 *
10 * Input: nums = ["3","6","7","10"], k = 4
11 * Output: "3"
12 * Explanation:
13 * The numbers in nums sorted in non-decreasing order are ["3","6","7","10"].
14 * The 4^th largest integer in nums is "3".
15 *
16 * Example 2:
17 *
18 * Input: nums = ["2","21","12","1"], k = 3
19 * Output: "2"
20 * Explanation:
21 * The numbers in nums sorted in non-decreasing order are ["1","2","12","21"].
22 * The 3^rd largest integer in nums is "2".
23 *
24 * Example 3:
25 *
26 * Input: nums = ["0","0"], k = 2
27 * Output: "0"
28 * Explanation:
29 * The numbers in nums sorted in non-decreasing order are ["0","0"].
30 * The 2^nd largest integer in nums is "0".
31 *
32 *
33 * Constraints:
34 *
35 * 1 <= k <= nums.length <= 10^4
36 * 1 <= nums[i].length <= 100
37 * nums[i] consists of only digits.
38 * nums[i] will not have any leading zeros.
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array/
44// discuss: https://leetcode.com/problems/find-the-kth-largest-integer-in-the-array/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn kth_largest_number(nums: Vec<String>, k: i32) -> String {
50 String::new()
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_1985() {
62 }
63}
64
Back
© 2025 bowen.ge All Rights Reserved.