C++ | O(N) time complexity solution
\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) {\n        // Time complexity - O(N)\n\t\t\n        int size = arr.size(), count=
```\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) {\n        // Time complexity - O(N)\n\t\t\n        int size = arr.size(), count=0, tcount=0, iptr=0, jptr=2;\n        string str = "", t = "", h1 = "", h2 = "";\n        vector<int>res(2,-1);\n        for(int i=0;i<size;i++){\n            str += (arr[i] ? \'1\' : \'0\');\n            count += arr[i];\n        }\n        if(count == 0){\n            res[0] = 0, res[1] = size-1;\n            return res;\n        }\n        if(count%3) return res;\n        count /= 3;\n        reverse(str.begin(), str.end());\n\t\t// reversed the string to easily process ending zeros of 3rd part in unreversed string\n\t\t\n        // find first part string for future comparision\n        tcount = 0;\n        for(int i=0;i<size && tcount < count;i++){\n            t += str[i];\n            if(str[i] == \'1\') tcount++;\n            jptr = i;\n        }\n        \n        // find second string for comparision\n        h1 = t, t = "";\n        tcount = 0;\n        for(int i=jptr+1;i<size && tcount < count;i++){\n            t += str[i];\n            if(str[i] == \'1\') tcount++;\n            iptr = i;\n        }\n        \n        if(t.length() < h1.length()) return res;\n        h2 = t.substr( (t.length()-h1.length()), h1.length() );\n        \n        if(h1 != h2) return res;\n        jptr += t.length()-h1.length();\n        \n        // find last string for comparision\n        t = "";\n        tcount = 0;\n        for(int i=iptr+1;i<size && tcount < count;i++){\n            t += str[i];\n            if(str[i] == \'1\') tcount++;\n        }\n        \n        if(t.length() < h1.length()) return res;\n        h2 = t.substr( (t.length()-h1.length()), h1.length() );\n        if(h1 != h2) return res;\n        \n        iptr += t.length()-h1.length();\n        \n        res[0] = size-1-(iptr+1);\n        res[1] = size-1-jptr;\n        return res;\n    }\n};\n```
['C']