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 :: How to redirect docker-compose command stdout stderr from docker container to file 
Shell :: http 192.168.l.l admin airtel 
Shell :: bash read -r option 
Shell :: How can I use Windows PowerShell to find the status of Hyper-V on my laptop running Windows 8.1? 
Shell :: What is the command to build image from Dockerfile and Podman 
Shell :: dgram i node 
Shell :: rar command line split size 
Shell :: Grep check 
Shell :: nginx dompdf error 
Shell :: query of meta command psql 
Shell :: kdevtmpfsi 
Shell :: history command windows 
Shell :: remove watermark in video in filmora 
Shell :: exiting nano 
Shell :: bash find files containing string 
Shell :: search in github repo 
Shell :: fix merge conflict in package-lock.json 
Shell :: export environment variable from bash script 
Shell :: pyglet linux 
Shell :: unstage particular file git 
Shell :: Git - add all changes files at same time for commit 
Shell :: linux shell system commands 
Shell :: install unifi controller raspberry pi 
Shell :: swap ctrl and caps lock linux 
Shell :: folding at home bash 
Shell :: see active apcahe conf file 
Shell :: apt mailbox debian 10 
Php :: php start session if not started 
Php :: generate random unique hex color code using php 
Php :: fluid inline if 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =