# 30.04.2025 [1295. Find Numbers with Even Number of Digits]
Even length numbers #easy
30.04.2025
1295. Find Numbers with Even Number of Digits easy blog post substack youtube
Join me on Telegram
Problem TLDR
Even length numbers #easy
Intuition
Do what is asked
Approach
some golf and counter acrobatics possible
how the input range can be used?
Complexity
Time complexity: $$O(n)$$
Space complexity: $$O(1)$$
Code
// 3ms
fun findNumbers(n: IntArray) =
n.count { "$it".length % 2 < 1 }
// 1ms
fun findNumbers(n: IntArray) = n
.count { it in 10..99 || it in 1000..9999 || it == 100000 }
// 0ms
pub fn find_numbers(n: Vec<i32>) -> i32 {
n.iter().map(|&x| { let (mut x, mut c) = (x, 1);
while x > 0 { x /= 10; c = 1 - c }; c
}).sum()
}
// 0ms
int findNumbers(vector<int>& n) {
int r = 0;
for (int c = 0; int x: n)
for (c = 1, r++; x > 0; x /= 10 ) r += 2 * (++c & 1) - 1;
return r;
}

