Skip to main content
Back to problems
Leetcode
Easy
Arrays
Math
Find Numbers With Even Number Of Digits

Count how many integers in an array have an even number of decimal digits.

Acceptance 0%
Problem Statement

Given an integer array nums, determine how many elements contain an even number of digits in base 10.

You only need to inspect each number independently and count its digits. Negative numbers are not part of the standard problem form; treat the input as non-negative integers.

Input Format

  • An integer array nums.
  • Each element of nums is a non-negative integer.

Output Format

Return the number of values in nums whose decimal representation has an even length.

Constraints

  • 1 <= nums.length is assumed in the standard problem.
  • Values are non-negative integers.
  • A direct per-element scan is sufficient.
Examples
Sample cases returned by the problem API.

Example 1

Input

nums = [12, 345, 2, 6, 7896]

Output

2

Explanation

12 has 2 digits and 7896 has 4 digits, so there are 2 numbers with an even number of digits.

Example 2

Input

nums = [555, 901, 482, 1771]

Output

1

Explanation

Only 1771 has an even number of digits.

Premium problem context

Unlock deeper context for this problem

Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.

Guided hints
Editorial and discussion links
Concept map and variants
Sign in to unlock
Track your progress
Sign in to bookmark this problem, save notes, and manage its revision plan.