Long and detailed Easy code C++ 99.17% faster
\nbool getmod2( vector<int>arr , int n , int sum )\n    {\n       \n        if( arr[sum] != 0 )\n        {\n            arr[sum]-- ;\n        }\n        else{\n
```\nbool getmod2( vector<int>arr , int n , int sum )\n    {\n       \n        if( arr[sum] != 0 )\n        {\n            arr[sum]-- ;\n        }\n        else{\n            return false ;\n        }\n        for( int i = 1 ; i < n ; i++ )\n        {\n            int r = sum%3 ;\n            \n            if( r == 0 )\n            {\n                if( arr[1] != 0 )\n                {\n                    sum += 1 ;\n                    arr[1]-- ;\n                }\n                else if( arr[2] != 0 )\n                {\n                    sum += 2 ;\n                    arr[2]-- ;\n                }\n                else{\n                    \n                    if( i%2 == 0 ) return false ;\n                    else{\n                        return true ;\n                    }\n                }\n            }\n            else if( r == 1 )\n            {\n                if( arr[0] != 0 )\n                {\n                    sum += 0 ;\n                    arr[0]-- ;\n                }\n                else if( arr[1] != 0 )\n                {\n                    sum += 1 ;\n                    arr[1]-- ;\n                }\n                else{\n                    \n                    if( i%2 == 0 ) return false ;\n                    else{\n                        return true ;\n                    }\n                }\n            }\n            else if( r == 2 )\n            {\n                if( arr[0] != 0 )\n                {\n                    sum += 0 ;\n                    arr[0]-- ;\n                }\n                else if( arr[2] != 0 )\n                {\n                    sum += 2 ;\n                    arr[2]-- ;\n                }\n                else{\n                    \n                    if( i%2 == 0 ) return false ;\n                    else{\n                        return true ;\n                    }\n                }\n            }\n        }\n        \n        return false ;\n    }\n    \n   \n    bool stoneGameIX(vector<int>& stones) {\n        \n        \n        vector<int>arr( 3 , 0 ) ;\n        \n        int n = stones.size()  ;\n        \n        for( int i = 0 ; i < n ; i++ )\n        {\n            arr[stones[i]%3]++ ;\n        }\n        \n        \n        \n        \n        \n        return getmod2( arr , n , 2 ) || getmod2( arr , n , 1 ) ;;\n        \n    }\n```
[]