Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Find The Least Frequent Digit

XPChallenge Points: 10
levelLevel: Easy

You are given an integer n. Consider how many times each digit (0 through 9) appears in its decimal form.
Your task is to identify the digit that appears the least number of times.
If more than one digit has the same lowest frequency, select the smallest digit among them.

Return this digit.

Example 1:

Input: n = 808080

Output: 8

Explanation:

Digits: 8 → appears 3 times 0 → appears 3 times Both have frequency 3, so pick the smallest → 8.

Example 2:

Input: n = 444123

Output: 1

Explanation:

Digit frequencies: 4 → 3 times 1 → 1 time 2 → 1 time 3 → 1 time The smallest digit among those with lowest frequency is 1.

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result