3663. Find The Least Frequent Digit Easy

@problem@discussion
#Array#Hash Table#Math#Counting



1/**
2 * [3663] Find The Least Frequent Digit
3 *
4 * Given an integer n, find the digit that occurs least frequently in its decimal representation. If multiple digits have the same frequency, choose the smallest digit.
5 * Return the chosen digit as an integer.
6 * The frequency of a digit x is the number of times it appears in the decimal representation of n.
7 *  
8 * <strong class="example">Example 1:
9 * <div class="example-block">
10 * Input: <span class="example-io">n = 1553322</span>
11 * Output: 1
12 * Explanation:
13 * The least frequent digit in n is 1, which appears only once. All other digits appear twice.
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">n = 723344511</span>
18 * Output: 2
19 * Explanation:
20 * The least frequent digits in n are 7, 2, and 5; each appears only once.
21 * </div>
22 *  
23 * Constraints:
24 * 
25 * 	1 <= n <= 2^31​​​​​​​ - 1
26 * 
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/find-the-least-frequent-digit/
31// discuss: https://leetcode.com/problems/find-the-least-frequent-digit/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36    pub fn get_least_frequent_digit(n: i32) -> i32 {
37        0
38    }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45    use super::*;
46
47    #[test]
48    fn test_3663() {
49    }
50}
51

Back
© 2026 bowen.ge All Rights Reserved.