24. Find Numbers with Even Number of Digits

EasyArrayArray

Given an array nums of integers, return how many of them contain an even number of digits.

Input: An integer array nums of length n.

Output: Integer — count of numbers with an even number of digits.

Examples

Example 1
Input: [12,345,2,6,7896]
Output: 2
Explanation: 12 has 2 digits (even). 345 has 3 (odd). 2 has 1 (odd). 6 has 1 (odd). 7896 has 4 (even). Count = 2.
Example 2
Input: [555,901,482,1771]
Output: 1
Explanation: 555→3 digits (odd). 901→3 (odd). 482→3 (odd). 1771→4 (even). Count = 1.
Example 3
Input: [1,22,333,4444,55555]
Output: 2
Explanation: 1→1(odd), 22→2(even), 333→3(odd), 4444→4(even), 55555→5(odd). Count = 2.

Constraints

Asked by

BloombergGoogleMetaAmazonMicrosoft
Solve this problem in the editor →