iOS Dev India
Learn
Roadmap
Skills
Swift DSA
Build
Studio
Sandbox
Tools
Agent Skills
Community
Communities
Events
Library
Articles
Resources
Jobs
Create Profile
Home
Learn
Roadmap
Skills
Swift DSA
Build
Studio
Sandbox
Tools
Agent Skills
Community
Communities
Events
Library
Articles
Resources
Jobs
Create Profile
Challenges
/
Count Vowels
·
Step 18/100 · Sets & Hashing
← Starts With Capital
Count Spaces →
Description
Hint
Count Vowels
L1
Easy
Strings
Concept
Searching a string for members of a small set of letters is a loop plus a membership check.
Count how many of the letters
a
,
e
,
i
,
o
, and
u
appear in
s
. Both uppercase and lowercase count.
Examples
▸
s = "hello"
→ 2
▸
s = "AEIOU"
→ 5
▸
s = "xyz"
→ 0
Progressive Hints
Hint 1 · Nudge
You're counting members of a tiny five-letter club.
Hint 2 · Plan
Turn the whole string lowercase so case stops mattering. Then loop and count every character that is one of a, e, i, o, u.
Hint 3 · Approach
count = 0. For each character c in the lowercased string: if c is one of the five vowels then count = count + 1. Return count.
Reveal the next hint
All hints are out. Take a breath and give it a shot.
Swift
Java
Solution.swift
Tests.swift (Read Only)
Run
Output
// Run your code to see the output here.
Press
ESC
to close.
Start typing to search...