Thinking the string as a Set with O(1) for look up operations: solution is O(n), where n = len(str)
vowels = "aeiouAEIOU"
count = 0
for c in str:
if c in vowels:
count += 1
JS lambda way
conat vowels = new Set("aeiouAEIOU");
const counVowels = input => [...input].reduce((total, current) => (total += vowels.has(current)), 0);
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.