![]() |
VOOZH | about |
Given a string, count the total number of vowels (a, e, i, o, u) in it. There are two methods to count total number of vowels in a string.
Examples:
Input : abc de Output : 2 Input : geeksforgeeks portal Output : 7
1. Iterative Method:
Below is the implementation:
2
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(1)
2. Recursive Method:
Below is the implementation:
2
Time Complexity: O(n), where n is the length of the string
Auxiliary Space: O(n), where n is the length of the string since the function is calling itself n times.
How Recursive Code Working.