very detailed and understandable explanation
\n    bool stoneGameIX(vector<int>& stones) {\n        vector<int> cnt(3);\n        for (int num: stones) {\n            cnt[num % 3]++;\n        }\n        // 
```\n    bool stoneGameIX(vector<int>& stones) {\n        vector<int> cnt(3);\n        for (int num: stones) {\n            cnt[num % 3]++;\n        }\n        // cnt[0] % 2 == 0 is equivalent to cnt[0] == 0, because a pair can be canceled out\n        \n        if (cnt[1] == 0 || cnt[2] == 0) {\n            // if cnt[0] == 0, e.g. (1, 1, 1) then Alice lose\n            // if max(cnt[1], cnt[2]) <= 2, then all numbers are exhausted, Alice lose\n            // otherwise, Alice win, e.g. (1, 1, 1, 3)\n            return cnt[0] % 2 == 1 && max(cnt[1], cnt[2]) >= 3;\n        } else {\n            // if there are both 1 and 2, then the pattern is\n            //    [1, 1, 2, 1, 2, 1, 2...], after 1st step, Alice needs 2 and Bob needs 1\n            // or [2, 2, 1, 2, 1, 2, 1...], after 1st step, Alice needs 1 and Bob needs 2\n            // the one who runs out of 1 or 2 first will lose\n            \n            // if cnt[0] == 0, then Alice win by starting with lower-count one, and Bob will runs out first. e.g. (1, 1, 2, 2) => [2, 2, 1,  (Bob lose with no more 2)]\n            if (cnt[0] % 2 == 0) {\n                return true;\n            }\n            \n            // now consider cnt[0] == 1, if abs(cnt[1] - cnt[2]) >= 3, Alice start with the higher-count one, this means Alice should lose, but since there is a 0, Alice can use it to force Bob to choose the lower one later\n            // e.g. (1, 1, 1, 1, 2, 0) => \n            // [1, 1, 0] + "now Bob is forced to choose lower one"\n            // overall it\'s [1, 1, 0, 2, 1,  (Bob lose with no more 2)]\n            \n            // what if Bob act first and use 0? the same outcome!\n            // [1, 0, 1] + "now Bob is forced to choose lower one" \n            // overall it\'s [1, 0, 1, 2, 1,  (Bob lose with no more 2)]\n            \n            if (abs(cnt[1] - cnt[2]) >= 3) {\n                return true;\n            }\n            \n            // however, the above case needs at least 3 more 1 than 2, otherwise, all numbers are exhausted and Alice lose, e.g. (1, 0, 1, 2, 1)\n            return false;\n        }\n    }\n```
[]