Skip to content

1295. Find Numbers with Even Number of Digits #1625

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

We need to determine how many numbers in a given array have an even number of digits.

Approach

The approach involves converting each number in the array to a string and checking the length of that string. If the length is even, we count that number. This method is straightforward and efficient given the constraints.

  1. Convert each number to a string: This allows us to easily determine the number of digits by checking the string length.
  2. Check if the string length is even: If the length is even, increment the count.
  3. Return the count: After processing all numbers, return the count of numbers with an even number of digits.

Let's implement this solution in PHP: 1295. Find Numbers with Even Num…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Apr 30, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested easy Difficulty
2 participants