Find The Least Frequent Digit
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.
Return the chosen digit as an integer.
The frequency of a digit x is the number of times it appears in the decimal representation of n.
Example 1
Input
n = 1553322Output
1The least frequent digit in
n is 1, which appears only once, while all other digits appear twice.Example 2
Input
n = 723344511Output
2The least frequent digits in
n are 7, 2, and 5; each appears only once, so the smallest is 2.Constraints
- 1 <= n <= 2^31 - 1