Class Solution
-
- All Implemented Interfaces:
public final class Solution3663 - Find The Least Frequent Digit.
Easy
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
xis the number of times it appears in the decimal representation ofn.Example 1:
Input: n = 1553322
Output: 1
Explanation:
The least frequent digit in
nis 1, which appears only once. All other digits appear twice.Example 2:
Input: n = 723344511
Output: 2
Explanation:
The least frequent digits in
nare 7, 2, and 5; each appears only once.Constraints:
<code>1 <= n <= 2<sup>31</sup> - 1</code>
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegergetLeastFrequentDigit(Integer n)-
-
Method Detail
-
getLeastFrequentDigit
final Integer getLeastFrequentDigit(Integer n)
-
-
-
-