← 返回 capitalone 的题目列表Count Numbers with Even Number of Digits
类型:online_judge
Problem
Given an integer array nums (each number may have multiple digits and can include 0), return the count of elements whose number of digits in base-10 is even.
The number of digits of x is the length of its decimal representation. For example, 7 has 1 digit, 12 has 2 digits, and 0 has 1 digit.
Input
An integer array nums
Output
An integer: the count of numbers with an even number of digits
Constraints (typical)
1 <= len(nums) <= 1e5
0 <= nums[i] <= 1e9
Examples
Input: [12, 345, 2, 6, 7896] → Output: 2
Input: [555, 901, 482, 1771] → Output: 1
Input: [0, 10, 100, 1000] → Output: 2
Input: [8] → Output: 0
Input: [22, 33, 4444, 5, 666666] → Output: 3
Example
Input
12 345 2 6 7896
Output
2