1481. Least Number of Unique Integers after K Removals Medium
1/**
2 * [1481] Least Number of Unique Integers after K Removals
3 *
4 * Given an array of integers arr and an integer k. Find the least number of unique integers after removing exactly k elements.
5 *
6 * <ol>
7 * </ol>
8 *
9 *
10 * Example 1:
11 *
12 *
13 * Input: arr = [5,5,4], k = 1
14 * Output: 1
15 * Explanation: Remove the single 4, only 5 is left.
16 *
17 * Example 2:
18 *
19 *
20 * Input: arr = [4,3,1,1,3,3,2], k = 3
21 * Output: 2
22 * Explanation: Remove 4, 2 and either one of the two 1s or three 3s. 1 and 3 will be left.
23 *
24 *
25 * Constraints:
26 *
27 *
28 * 1 <= arr.length <= 10^5
29 * 1 <= arr[i] <= 10^9
30 * 0 <= k <= arr.length
31 *
32 */
33pub struct Solution {}
34
35// problem: https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/
36// discuss: https://leetcode.com/problems/least-number-of-unique-integers-after-k-removals/discuss/?currentPage=1&orderBy=most_votes&query=
37
38// submission codes start here
39
40impl Solution {
41 pub fn find_least_num_of_unique_ints(arr: Vec<i32>, k: i32) -> i32 {
42
43 }
44}
45
46// submission codes end
47
48#[cfg(test)]
49mod tests {
50 use super::*;
51
52 #[test]
53 fn test_1481() {
54 }
55}
56
Back
© 2025 bowen.ge All Rights Reserved.