[JAVA] easy to understand guarnteed :)
\nclass Solution {\n    int[] stones;\n    public boolean stoneGameIX(int[] stones) {\n        this.stones = stones;\n        int [] freq = new int[3];\n       
```\nclass Solution {\n    int[] stones;\n    public boolean stoneGameIX(int[] stones) {\n        this.stones = stones;\n        int [] freq = new int[3];\n        \n        for (int i : stones) {\n            if (i % 3 == 0) freq[0]++;\n            else if (i % 3 == 1) freq[1]++;\n            else freq[2]++;\n        }\n        \n        boolean A = false;\n        boolean B = false;\n        int[] a = freq.clone();\n        int[] b = freq.clone();\n        if (a[1] > 0) {\n            a[1]--;\n            A = fun(a, 1);\n        }\n        if (b[2] > 0) {\n            b[2]--;\n            B = fun(b, 2);\n        }\n        return A || B ;\n    }\n    \n    private boolean fun (int[] freq, int sum) {\n        int n = stones.length;\n        int i = 1;\n        while (i < n) {\n            if (i % 2 == 0) {   // alice turn\n                if (sum % 3 == 1) {\n                    if (freq[0] > 0) freq[0]--;\n                    else if (freq[1] > 0) {\n                        freq[1]--;\n                        sum += 1;\n                    } else return false;\n                    \n                } else if (sum % 3 == 2) {\n                    if (freq[0] > 0) freq[0]--;\n                    else if (freq[2] > 0) {\n                        freq[2]--;\n                        sum += 2;\n                    }\n                    else return false;\n                }\n                    \n            } else {    // bob\'s turn\n                if (sum % 3 == 2) {\n                    if (freq[0] > 0) freq[0]--;\n                    else if (freq[2] > 0) {\n                        freq[2]--;\n                        sum += 2;\n                    }\n                    else return true;\n                    \n                } else if (sum % 3 == 1) {\n                    if (freq[0] > 0) freq[0]--;\n                    else if (freq[1] > 0) {\n                        freq[1]--;\n                        sum += 1;\n                    } else return true;\n                }\n            }\n            i++;\n        }\n        return false;\n    }\n}\n```
[]