1295: Find-Numbers-with-Even-Number-of-Digits
Easy


table of contents

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) {
            string temp = to_string(num);
            if (temp.size() % 2 == 0) {
                ++ans;
            }
        }
        return ans;
    }
};

complexity

time taken