Count Odd Letters from Number - Problem

You are given an integer n. Perform the following steps:

  1. Convert each digit of n into its lowercase English word (e.g., 4 → "four", 1 → "one")
  2. Concatenate those words in the original digit order to form a string s
  3. Return the number of distinct characters in s that 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
Count Odd Letters from Number: 234234twothreefourtwothreefourCharacters with odd frequency: w(1), r(3), f(1), u(1)Result: 4
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
Asked in
Google 25 Meta 18 Amazon 15
23.0K Views
Medium Frequency
~15 min Avg. Time
847 Likes
Ln 1, Col 1
Smart Actions
💡 Explanation
AI Ready
💡 Suggestion Tab to accept Esc to dismiss
// Output will appear here after running code
Code Editor Closed
Click the red button to reopen