1295: Find-Numbers-with-Even-Number-of-Digits
Easy
Basically, just iterate through all the numbers in
nums
, convert them to string and check the length of
the string and see if it is divisible by 2.
Code:
class Solution {
public:
int findNumbers(vector<int>& nums) {
int ans = 0;
for (int num : nums) {
= to_string(num);
string temp if (temp.size() % 2 == 0) {
++ans;
}
}
return ans;
}
};