Given a string s, return the count of vowels in the string.
Explanation: Step-by-step: with input 'Hello World', we convert the string to lowercase using the tolower() method, then iterate over each character. If the character is a vowel, we increment the count. Finally, we return the count. The vowels in 'Hello World' are 'e', 'o', and 'o', so the output is 3.
Explanation: Step-by-step: with input 'AEIOU', we convert the string to lowercase using the tolower() method, then iterate over each character. If the character is a vowel, we increment the count. Finally, we return the count. The vowels in 'AEIOU' are 'a', 'e', 'i', 'o', and 'u', so the output is 5.
Analyze constraints and compute optimal solutions step-by-step.
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak