✨[TYPESCRIPT]✨ 100 ms Beats 100.00% ✅
Intuition\n\nSimulation\n\n# Code\n\nts\nfunction stoneGameIX(stones: number[]): boolean {\n  if (stones.length === 1) return false\n\n  const cnt = Array(3).fi
# Intuition\n\nSimulation\n\n# Code\n\n```ts\nfunction stoneGameIX(stones: number[]): boolean {\n  if (stones.length === 1) return false\n\n  const cnt = Array(3).fill(0)\n  for (const x of stones) cnt[x % 3]++\n\n  const check = (x: number, cnt: number[]): boolean => {\n    let c = 1\n    if (--cnt[x] < 0) return false\n\n    while (cnt[1] || cnt[2]) {\n      if (cnt[x]) {\n        cnt[x]--\n        x = x === 1 ? 2 : 1\n      } else return (c + cnt[0]) % 2 === 1\n      c++\n    }\n\n    return false\n  }\n\n  return check(1, [...cnt]) || check(2, [...cnt])\n}\n```\n\n## **Please upvote \uD83D\uDC4D if you like \u2764\uFE0F my solution**
['Array', 'Math', 'Greedy', 'Counting', 'Game Theory', 'TypeScript', 'JavaScript']