LeetCode in Kotlin

3227. Vowels Game in a String

Medium

Alice and Bob are playing a game on a string.

You are given a string s, Alice and Bob will take turns playing the following game where Alice starts first:

The first player who cannot make a move on their turn loses the game. We assume that both Alice and Bob play optimally.

Return true if Alice wins the game, and false otherwise.

The English vowels are: a, e, i, o, and u.

Example 1:

Input: s = “leetcoder”

Output: true

Explanation:
Alice can win the game as follows:

Example 2:

Input: s = “bbcd”

Output: false

Explanation:
There is no valid play for Alice in her first turn, so Alice loses the game.

Constraints:

Solution

class Solution {
    fun doesAliceWin(s: String): Boolean {
        for (element in s) {
            if (element == 'a' || element == 'e' || element == 'i' || element == 'o' || element == 'u') {
                return true
            }
        }
        return false
    }
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy