Skip to content

Commit 18d24dd

Browse files
committed
Add solution #3227
1 parent ca366ba commit 18d24dd

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,7 @@
26832683
3215|[Count Triplets with Even XOR Set Bits II](./solutions/3215-count-triplets-with-even-xor-set-bits-ii.js)|Medium|
26842684
3221|[Maximum Array Hopping Score II](./solutions/3221-maximum-array-hopping-score-ii.js)|Medium|
26852685
3223|[Minimum Length of String After Operations](./solutions/3223-minimum-length-of-string-after-operations.js)|Medium|
2686+
3227|[Vowels Game in a String](./solutions/3227-vowels-game-in-a-string.js)|Medium|
26862687
3231|[Minimum Number of Increasing Subsequence to Be Removed](./solutions/3231-minimum-number-of-increasing-subsequence-to-be-removed.js)|Hard|
26872688
3237|[Alt and Tab Simulation](./solutions/3237-alt-and-tab-simulation.js)|Medium|
26882689
3247|[Number of Subsequences with Odd Sum](./solutions/3247-number-of-subsequences-with-odd-sum.js)|Medium|
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* 3227. Vowels Game in a String
3+
* https://leetcode.com/problems/vowels-game-in-a-string/
4+
* Difficulty: Medium
5+
*
6+
* Alice and Bob are playing a game on a string.
7+
*
8+
* You are given a string s, Alice and Bob will take turns playing the following game where
9+
* Alice starts first:
10+
* - On Alice's turn, she has to remove any non-empty substring from s that contains an odd
11+
* number of vowels.
12+
* - On Bob's turn, he has to remove any non-empty substring from s that contains an even
13+
* number of vowels.
14+
*
15+
* The first player who cannot make a move on their turn loses the game. We assume that both
16+
* Alice and Bob play optimally.
17+
*
18+
* Return true if Alice wins the game, and false otherwise.
19+
*
20+
* The English vowels are: a, e, i, o, and u.
21+
*/
22+
23+
/**
24+
* @param {string} s
25+
* @return {boolean}
26+
*/
27+
var doesAliceWin = function(s) {
28+
const vowels = new Set(['a', 'e', 'i', 'o', 'u']);
29+
for (const char of s) {
30+
if (vowels.has(char)) {
31+
return true;
32+
}
33+
}
34+
return false;
35+
};

0 commit comments

Comments
 (0)