Greedy O(n)
Intuition\nThis take me very long trial and error to arrive at this conclusion:\n- We can easily see that the actual value of the stones does not matter much, o
# Intuition\nThis take me very long trial and error to arrive at this conclusion:\n- We can easily see that the actual value of the stones does not matter much, only it\'s value in modulo 3 is important. Let $group(i)$ be the number of stones that has value $i$ in modulo 3\n- The game entirely depends on the first pick from Alice\n    - Alice pick 1, the game would be 1,1,2,1,2,1,2 ...\n    - Alice pick 2, the game would be 2,2,1,2,1,2,1,2 ...\n    - The game end when 1 person fail to match the pick\n    - Pick 0 will result in reverse play (making other person to match his own previous pick)\n- If $group(0)$ is even, and $group(1) > 0, group(2) > 0$, Alice can always force a win by picking the group with less number. If $group(1) = 0$ or $group(2) = 0$, Alice will always end up running out of good number to pick and thus losing\n- If $group(0)$ is odd, Alice need to pick a group has more than at least 2 number than the other group, otherwise she will always lose\n# Complexity\n- Time complexity: $O(n)$\n- Space complexity: $O(1)$\n\n# Code\n```\nuse std::collections::HashMap;\nimpl Solution {\n    pub fn stone_game_ix(stones: Vec<i32>) -> bool {\n        let n = stones.len();\n        let mut group = vec![0i32;3];\n        for x in stones {\n            group[(x%3) as usize] += 1;\n        }\n        if group[0]%2 == 0  {\n            group[1] > 0 && group[2] > 0\n        } else {\n            (group[1] - group[2]).abs() > 2\n        }\n    }\n}\n```
['Rust']