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:
6
💡 Note:
234 → "two" + "three" + "four" = "twothreefour". Character frequencies: t(2), w(1), o(2), h(1), r(3), e(3), f(1), u(1). Characters with odd frequency: w(1), h(1), r(3), e(3), f(1), u(1) = 6 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
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code