Problem of The Day: Vowels Game in a String
Problem Statement
Brute Force approach [Accepted]
class Solution:
def doesAliceWin(self, s: str) -> bool:
vowels = {'a','e','i','o','u'}
vowel_count = 0
non_vowel = 0
for c in s:
if c in vowels:
vowel_count += 1
else:
non_vowel += 1
if vowel_count == 0:
return False
if vowel_count % 2 != 0:
return True
return True
Editorial
Approach: Greedy
class Solution:
def doesAliceWin(self, s: str) -> bool:
return any(c in "aeiou" for c in s)