Atom feed

Recently added: 128 Longest Consecutive Sequence, 347 Top K Frequent Elements, 045 Jump Game 2, 228 Summary Ranges, 219 Contains Duplicate 2

01 Monk Takes Walk

 * Created by Ashish Patel
 * Copyright © 2018

/* Today, Monk went for a walk in a garden. There are many trees in the garden and each tree has an English alphabet on it. While Monk was walking, he noticed that all trees with vowels on it are not in good state. He decided to take care of them. So, he asked you to tell him the count of such trees in the garden. 
Note : The following letters are vowels: 'A', 'E', 'I', 'O', 'U' ,'a','e','i','o' and 'u'.

The first line consists of an integer T denoting the number of test cases.
Each test case consists of only one string, each character of string denoting the alphabet (may be lowercase or uppercase) on a tree in the garden.

For each test case, print the count in a new line. */

const stdInput = 

function main(input) {
    const inputArray = input.split('\n');
    const numOfStrings = Number(inputArray[0]);
    for(let i=1; i<=numOfStrings; i++) { 
        const vowels = inputArray[i].match(/[aeiou]/gi) || [];
        vowels.length > 0 ? console.log(vowels.length) : console.log(0);  


Created 2019-11-30T02:13:21+05:30 · Edit