1295. Find Numbers with Even Number of Digits

1295. Find Numbers with Even Number of Digits

class Solution {
    public int countDigits(int num){
        int count = 1;
        while(num /10 !=0){
            num = num /10;
            count++;
        }
        return count;
    }
    public int findNumbers(int[] nums) {
        int count = 0;
        for (int i = 0; i < nums.length; i++){
            if(countDigits(nums[i]) % 2 == 0) count++;
        }
        return count;
    }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s