Skip to main content

Find Numbers with Even Number of Digits

EasyArrayMath

Description

Given an array nums of integers, return how many of them contain an even number of digits. For example, 12 has 2 digits (even), 123 has 3 digits (odd).

Examples

Input:nums = [12,345,2,6,7896]
Output:2
Explanation:

12 has 2 digits and 7896 has 4 digits (both even). The numbers 345 (3 digits), 2 (1 digit), and 6 (1 digit) have odd digit counts.

Input:nums = [1,22,333,4444,55555]
Output:2
Explanation:

22 has 2 digits (even) and 4444 has 4 digits (even). The numbers 1, 333, and 55555 have 1, 3, and 5 digits respectively (all odd).

Input:nums = [9,8,7,6,5]
Output:0
Explanation:

All numbers are single digits (1 digit each), which is odd. Therefore, no numbers have an even number of digits.

Constraints

  • 1 ≤ nums.length ≤ 500

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.