Given an array of positive integers numbers, calculate how many of its elements have an even number of digits.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers.length2) will fit within the execution time limit.
Examples
01 · Example 1
numbers = [12, 134, 111, 1111, 10] return = 3
numbers[0] = 12has2digits, which is an even number.numbers[1] = 134has3digits, which is not an even number.numbers[2] = 111has3digits, which is not an even number.numbers[3] = 1111has4digits, which is an even number.numbers[4] = 10has2digits, which is an even number.
There are 3 elements, numbers[0], numbers[3], and numbers[4], with an even number of digits.
Constraints
1 <= numbers.length <= 10001 <= numbers[i] <= 104
More Tiktok problems
- Check Even-Position MonotonicityOA · Seen Jun 2026
- Count Alternating Tile GroupsOA · Seen Jun 2026
- Inventory Discount TrackerOA · Seen Jun 2026
- Construct WDL StringOA · Seen Jun 2026
- Find Sum PairsOA · Seen Jun 2026
- LRU Cache with TTL ExpirationONSITE INTERVIEW · Seen May 2026
- Maximum Candies with At Most Two Types in a LineONSITE INTERVIEW · Seen May 2026
- Top-K KOLs by Total LikesONSITE INTERVIEW · Seen May 2026
public int solution(int[] numbers) {
// write your code here
}numbers[12, 134, 111, 1111, 10]
expected3
sign in to submit