Given a string ‘STR’ which consists of uppercase and lowercase characters and spaces. Count the number of consonants in the string.
A consonant is an English alphabet character that is not vowel (a, e, i, o, and u). Examples of constants are b, c, d, f, etc.
Example :
Given string 'STR' : ‘Coding Ninjas’ there are 8 consonants i.e ‘C’,’d’,’n’,’g’,’N’,’n’,’j’,’s’, because these characters do not belong to set above mentioned set of vowels.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The next ‘T’ lines represent the ‘T’ test cases.
The only line of each test case consists of a string ‘STR’
Output Format :
For each test case, print a single integer denoting the number of consonants in the string.
Note :
You don't need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 50
1 <= Length of 'STR' <= 10^4
The string consists of uppercase and lowercase characters and spaces.
Time Limit: 1 sec
2
Coding Ninjas
MacBook Pro
8
6
Test Case 1 :

Consider the above figure:
The Characters highlighted in red are consonants we can clearly see that there are 8 consonants in the given string. Therefore we print 8.
Test Case 2 :

The Characters highlighted in red are consonants we can clearly see that there are 6 consonants in the given string. Therefore we print 6.
2
BANANA
mango
3
3
We can clearly see that banana and mango each have 3 consonants, therefore we return 3 for both of them
Find all consonants recursively
If we can find if the current character is a consonant or not we can create a recursive to count all the vowels.
O(N), where ‘N’ denotes the size of the string.
In each recursive call, we just check if it is a consonant or not which is a constant time operation, and we do this for all characters of the string. Hence, the overall time complexity will be O(N).
O(N), where ‘N’ denotes the size of the string.
The space complexity is the order of ‘N’ because in the case of recursion the space complexity is proportional to the depth of the recursion tree, which in this case is proportional to the size of the string. Hence, the overall space complexity will be O(N).