Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Problem {
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- ArrayList<Integer> list = new ArrayList<>();
- for(int i=0; i<n; i++){
- int num = sc.nextInt();
- list.add(num);
- }
- System.out.println(countOddDigitNumbers(list, n));
- }
- public static int countOddDigitNumbers(ArrayList<Integer> list, int n){
- int count = 0;
- for(int num : list){
- if(hasOddDigits(num))
- count++;
- }
- return count;
- }
- public static boolean hasOddDigits(int num){
- int digits = 0;
- while (num > 0){
- digits++;
- num /= 10;
- }
- return digits%2 == 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement