Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com

# Count vowels, consonants, and spaces

Easy
0/40
Average time to solve is 10m
Contributed by

## Problem statement

Given a string, write a program to count the number of vowels, consonants, and spaces in that string.

EXAMPLE :
``````Input: ‘N’= 25, ‘s’ =”Take u forward is Awesome”
Output: 10 11 4
``````
Detailed explanation ( Input/output format, Notes, Images )
Constraints :
``````1 <= 'T' <= 10
1 <= 'N' <= 10^5
It is guaranteed that sum of ‘N’ over all test cases is <= 10^5
Time Limit: 1 sec
``````
##### Sample Input 1 :
``````2
25
Take u forward is Awesome
27
India won the cricket match
``````
##### Sample Output 1 :
``````10 11 4
8 15 4
``````
##### Explanation Of Sample Input 1 :
``````Note: Ignore the inverted commas at the start and end of the string, they are just to make it visually better to understand the given string.
The first test case is the same as the explanation above.

For the second test case, the vowels are at indices {1, 4, 5, 8, 13, 17, 20, 24} and spaces are at indices {6, 10, 14, 22} rest indices are consonants i.e. (27 - 8 - 4) = 15.

Hence, the output will be: 8 15 4
``````
##### Sample Input 2 :
``````2
12
hEllOWorlD
2
``````
##### Sample Output 2 :
``````3 7 2
0 0 2
``````
Console