Find Numbers with Even Number of Digits - Problem
Given an array nums of integers, return how many of them contain an even number of digits.
A number has an even number of digits if the count of its digits is divisible by 2.
Example: The number 123 has 3 digits (odd), while 1234 has 4 digits (even).
Input & Output
Example 1 — Basic Mixed Array
$
Input:
nums = [12,345,2,6,7896]
›
Output:
2
💡 Note:
12 has 2 digits (even), 345 has 3 digits (odd), 2 has 1 digit (odd), 6 has 1 digit (odd), 7896 has 4 digits (even). Total numbers with even digits: 2
Example 2 — All Single Digits
$
Input:
nums = [7,8]
›
Output:
0
💡 Note:
7 has 1 digit (odd), 8 has 1 digit (odd). No numbers have even digit count.
Example 3 — Large Numbers
$
Input:
nums = [555,901,482,1771]
›
Output:
1
💡 Note:
555 has 3 digits (odd), 901 has 3 digits (odd), 482 has 3 digits (odd), 1771 has 4 digits (even). Only 1771 has even digits.
Constraints
- 1 ≤ nums.length ≤ 500
- 1 ≤ nums[i] ≤ 105
Visualization
Tap to expand
Understanding the Visualization
1
Input Array
Array of integers to analyze
2
Count Digits
For each number, determine how many digits it has
3
Count Even
Count how many numbers have even digit counts
Key Takeaway
🎯 Key Insight: Count digits for each number and check if the count is divisible by 2
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code