Competitive Programming Solutions

GitHub
back to dashboard

I. Count Vowels

Codeforces - Sheet #7 (Recursion) · limit: 1s · memory: 256MB · view on codeforces

input

Data Structure Lab

output

6
Main.java
static void solve() {

        // Write your solution here
        String S = in.nextLine();
        Set<Character> vowels = new HashSet<>(Arrays.asList('a','e','i','o','u'));
        int count = 0;
        for(char c: S.toCharArray()){
            if(vowels.contains(Character.toLowerCase(c))) count++;
        }
        out.println(count);
    }