C++ 22 lines ,O(n) time Soluton
\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& A) {\n        int v[30005];\n        int cnt = 0,n = A.size();\n        for(int i=0;i<
```\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& A) {\n        int v[30005];\n        int cnt = 0,n = A.size();\n        for(int i=0;i<n;i++)if(A[i])v[cnt++] = i;\n        if (cnt%3!=0) return {-1,-1};\n        if (cnt == 0) return {0, n-1};\n        int a = v[0];\n        int b = v[cnt/3];\n        int c = v[cnt/3*2];\n        int ed = b,ed2 = c;\n        int num = 0;\n        while(a<ed && b<ed2 && c<n){\n            if(A[a]!= A[b] || A[a]!=A[c] || A[b]!=A[c])return {-1,-1};\n            num += A[a];\n            if(num==cnt/3 && c==n-1)return {a,b+1};\n            a++;b++;c++;\n        }\n        return {-1,-1};\n    }\n};\n```
[]