[LeetCode] Find Numbers with Even Number of Digits

1295. Find Numbers with Even Number of Digits

Given an array nums of integers, return how many of them contain an even number of digits.

1
2
3
4
5
6
7
8
class Solution {
public:
int findNumbers(vector<int>& nums) {
int res = 0;
for(auto& n : nums) res += ((int)log10(n) & 1);
return res;
}
};
Author: Song Hayoung
Link: https://songhayoung.github.io/2025/04/30/PS/LeetCode/find-numbers-with-even-number-of-digits/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.