Count Odd Letters from Number - Problem
You are given an integer n. Perform the following steps:
- Convert each digit of
ninto its lowercase English word (e.g., 4 → "four", 1 → "one") - Concatenate those words in the original digit order to form a string
s - Return the number of distinct characters in
sthat appear an odd number of times
For example, if n = 234, we get "twothreefour", then count how many unique characters appear an odd number of times.
Input & Output
Example 1 — Basic Case
$
Input:
n = 234
›
Output:
4
💡 Note:
234 → "two" + "three" + "four" = "twothreefour". Characters with odd frequency: w(1), r(3), f(1), u(1) = 4 total
Example 2 — Single Digit
$
Input:
n = 5
›
Output:
4
💡 Note:
5 → "five". Characters: f(1), i(1), v(1), e(1). All 4 characters appear once (odd) = 4 total
Example 3 — Repeated Digits
$
Input:
n = 101
›
Output:
1
💡 Note:
101 → "one" + "zero" + "one" = "onezeroone". Most characters appear even times, only 'z' appears 1 time (odd) = 1 total
Constraints
- 1 ≤ n ≤ 109
Visualization
Tap to expand
Understanding the Visualization
1
Input
Integer n = 234
2
Convert
2→two, 3→three, 4→four → twothreefour
3
Count
Find characters with odd frequencies
Key Takeaway
🎯 Key Insight: Convert digits to English words, concatenate, then use frequency counting to find characters appearing odd times
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code