![]() |
VOOZH | about |
Given a string, count total number of consonants in it. 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, and g.
Examples :
Input : abc de Output : 3 There are three consonants b, c and d. Input : geeksforgeeks portal Output : 12
1. Iterative Method
3
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(1)
2. Recursive Method
3
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(n), due to recursive call stacks.
Illustration of recursive method: