[Python3] freq table
Intuition\nHere, the specific numbers don\'t matter. Only the modulos do. \nIn order for Alice to win, the sequence would be like \n1) 1(12)(12)...(12)2 with ev
**Intuition**\nHere, the specific numbers don\'t matter. Only the modulos do. \nIn order for Alice to win, the sequence would be like \n1) 1(12)(12)...(12)2 with even number of 0\'s between first 1 and final 2\n2) 1(12)(12)...(12)11 with odd number of 0\'s between first 1 and final 1\n\nwhere 1\'s and 2\'s are interchangable due to symmetry. So the strategy is \n1) if there are even number of 0\'s, Alice would choose 1 or 2 whoever is less or equal frequent as long as they both exist. Without loss of generality, let\'s say 1 is less frequent. In this case, it is guranteed to be Bob\'s turn to place the last number 2 when they run out of 1\'s. \n2) if there are odd number of 0\'s, Alice would choose 1 or 2 whoever is more frequent. Let\'s say 1 is more frequent in the input. In this case, Alice need three extra 1\'s to win. Besides, it is not difficult to figure out that as long as there are three (or more) extra 1\'s Alice will win. \n\n```\nclass Solution:\n    def stoneGameIX(self, stones: List[int]) -> bool:\n        freq = defaultdict(int)\n        for x in stones: freq[x % 3] += 1\n        \n        if freq[0]%2 == 0: return freq[1] and freq[2]\n        return abs(freq[1] - freq[2]) >= 3\n```
['Python3']