C++ O(n) time and O(1) space
\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) {\n        int count = 0;\n        for (auto i:arr)\n        {\n            if(i 
```\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) {\n        int count = 0;\n        for (auto i:arr)\n        {\n            if(i == 1)\n                count++;\n        }\n        if(count == 0)\n            return {0,2};\n        if(count%3 != 0)\n            return {-1,-1};\n        int p1 = 0;\n        int p2 = 0;\n        int p3 = 0;\n        count = count/3;\n        int temp = 0;\n        for(int i = 0;i<arr.size();i++)\n        {  if(arr[i] == 1)\n          { if(temp == 0)\n              p1 = i;\n            else if(temp == count)\n                p2 = i;\n             else if(temp == 2*count)\n                p3 = i;\n           temp++;\n          }\n        \n        }\n\n        int oldp2 = p2;\n        int oldp3 = p3;\n        while(p1<oldp2 and p2<oldp3 and p3<arr.size())\n        {\n            if(arr[p1] != arr[p2] or arr[p2] != arr[p3])\n                return {-1,-1};\n            p1++;\n            p2++;\n            p3++;\n        }\n        if(p3 == arr.size())\n        {\n            return {p1-1,p2};\n        }\n        return {-1,-1};\n    }\n};\n```
[]