Skip to content

Commit 7bf6cf7

Browse files
authored
Create 2029-stone-game-ix.js
1 parent 9b6f4b4 commit 7bf6cf7

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

2029-stone-game-ix.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @param {number[]} stones
3+
* @return {boolean}
4+
*/
5+
const stoneGameIX = function(stones) {
6+
const cnt = Array(3).fill(0), { abs } = Math
7+
for (let a of stones) cnt[a % 3]++;
8+
if (cnt[0] % 2 == 0) return cnt[1] && cnt[2]
9+
return abs(cnt[1] - cnt[2]) >= 3
10+
};

0 commit comments

Comments
 (0)