BackmediumArrays Razorpay Atlassian

string vowels Solution

Problem Statement

Given a string s, return the count of vowels in the string.

Example 1
Input
Hello World
Output
3

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.

Example 2
Input
AEIOU
Output
5

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.

Constraints

  • 1 <= length of string <= 10^5
  • string contains only lowercase English letters
  • string can be empty
Live Compiler
Loading...
Test Cases & Output
🔒 Sign up to run your code

🚀 Practice this problem

Run code, get AI hints & track streak

Sign Up Free