3852. Smallest Pair With Different Frequencies Easy

@problem@discussion



1/**
2 * [3852] Smallest Pair With Different Frequencies
3 *
4 * You are given an integer array nums.
5 * Consider all pairs of distinct values x and y from nums such that:
6 * 
7 * 	x < y
8 * 	x and y have different <span data-keyword="frequency-array">frequencies</span> in nums.
9 * 
10 * Among all such pairs:
11 * 
12 * 	Choose the pair with the smallest possible value of x.
13 * 	If multiple pairs have the same x, choose the one with the smallest possible value of y.
14 * 
15 * Return an integer array [x, y]. If no valid pair exists, return [-1, -1].
16 *  
17 * <strong class="example">Example 1:
18 * <div class="example-block">
19 * Input: <span class="example-io">nums = [1,1,2,2,3,4]</span>
20 * Output: <span class="example-io">[1,3]</span>
21 * Explanation:
22 * The smallest value is 1 with a frequency of 2, and the smallest value greater than 1 that has a different frequency from 1 is 3 with a frequency of 1. Thus, the answer is [1, 3].
23 * </div>
24 * <strong class="example">Example 2:
25 * <div class="example-block">
26 * Input: <span class="example-io">nums = [1,5]</span>
27 * Output: <span class="example-io">[-1,-1]</span>
28 * Explanation:
29 * Both values have the same frequency, so no valid pair exists. Return [-1, -1].
30 * </div>
31 * <strong class="example">Example 3:
32 * <div class="example-block">
33 * Input: <span class="example-io">nums = [7]</span>
34 * Output: <span class="example-io">[-1,-1]</span>
35 * Explanation:
36 * There is only one value in the array, so no valid pair exists. Return [-1, -1].
37 * </div>
38 *  
39 * Constraints:
40 * 
41 * 	1 <= nums.length <= 100
42 * 	1 <= nums[i] <= 100
43 * 
44 */
45pub struct Solution {}
46
47// problem: https://leetcode.com/problems/smallest-pair-with-different-frequencies/
48// discuss: https://leetcode.com/problems/smallest-pair-with-different-frequencies/discuss/?currentPage=1&orderBy=most_votes&query=
49
50// submission codes start here
51
52impl Solution {
53    pub fn min_distinct_freq_pair(nums: Vec<i32>) -> Vec<i32> {
54        vec![]
55    }
56}
57
58// submission codes end
59
60#[cfg(test)]
61mod tests {
62    use super::*;
63
64    #[test]
65    fn test_3852() {
66    }
67}
68

Back
© 2026 bowen.ge All Rights Reserved.