Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

leetcode even digits

// https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
// Find Numbers with Even Number of Digits

class Solution {
    public int findNumbers(int[] nums) {
        int evenDigits = 0;
        for (int num : nums) {
            if (isEvenDigit(num)) evenDigits++;
        }
        return evenDigits;
    }
/*	
	// counting the number of digits (Method 1)
    int digitcount2(int number) {

        if (number < 0) number *= -1;
        if (number == 0) return 1;
        int count = 0;
        while (number > 0) {
            number /= 10;
            count++;
        }
        return count;
    }
*/  
	// counting the number of digits (Method 2)
  	int digitcount(int number){
        return (int) (Math.log10(number)) + 1;
    }
  
    boolean isEvenDigit(int number){
        return digitcount(number) % 2 == 0;
    }
}
Comment

leetcode even digits


int findNumbers(int* nums, int numsSize){
        
        int c = 0;
        
        for(int i = 0; i < numsSize; i++){
               
                if(numDigit(nums[i]) % 2 == 0){
                        c++;
                } 
        }

        return c;
}

Comment

Find Numbers with Even Number of Digits leetcode

// https://leetcode.com/problems/find-numbers-with-even-number-of-digits/
// Find Numbers with Even Number of Digits

class Solution {
    public int findNumbers(int[] nums) {
        int count=0;
        for(int i =0 ; i< nums.length; i++){
            if((nums[i]>9 && nums[i]<100) || (nums[i]>999 && nums[i]<10000) || nums[i]==100000){
                count++;
            }
        }
        return count;
    }
}
Comment

PREVIOUS NEXT
Code Example
Shell :: unzip start of central directory not found 
Shell :: install phpcs laravel 
Shell :: screenshot with annotation 
Shell :: commit our changes and merge them back into our dev branch. 
Shell :: msg="could not create cluster: could not create pod disruption budget: poddisruptionbudgets.policy "postgres-fx-postgres-pdb" already exists" 
Shell :: Installing YouTube-DL on WSL2 Arch Linux 
Shell :: increase filesystem space in aix 
Shell :: cmd mac pdf reader 
Shell :: command to reload a system service 
Shell :: alembic not found 
Shell :: ffmpeg add cover art 
Shell :: does electron app work in ubuntu 
Shell :: docker compose linux +group_add uid sid 
Shell :: unix symbolic link 
Shell :: openssl command 
Shell :: fslmaths threshold 
Shell :: davinci resolve system requirements 
Shell :: windoes debloat 
Shell :: unix file systems 
Shell :: unity for ubuntu 20.04 
Shell :: ubuntu xampp apache web server running 
Shell :: git change commit message for merge 
Shell :: command to delete a directory in linux 
Shell :: how to install brave browser on manjaro 
Shell :: btfs paket ubunt 
Shell :: ubuntu video duplicate finder 
Shell :: find all file with tilda sign? 
Php :: php artisan clear commands 
Php :: composer update memory limit 
Php :: wordpress get domain 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =