Java easy O(N), 1ms, with comments
refactored  version :\n\n    public int[] threeEqualParts(int[] arr) {\n        int len=arr.length, onesCount=0;\n        int[] fail = new int[]{-1,-1};  //erro
refactored  version :\n```\n    public int[] threeEqualParts(int[] arr) {\n        int len=arr.length, onesCount=0;\n        int[] fail = new int[]{-1,-1};  //error case return\n      \n        //every part of tree may have a variable number of zeros due to leading zeros, while\n        //number of ones should be the same in all parts;\n        //let\'s count overall number of ones\n        for(int a : arr)  \n            onesCount+=a;\n        \n        //if overall number of ones can\'t be divided equally between all three parts, then we return error\n        if(onesCount%3!=0 )\n            return fail;\n        \n        //in case of absence of ones, let\'s return any possible combination\n        if(onesCount==0)\n            return new int[]{0,2};\n\n        int i,j,k,m,l;\n        int partOnesCount =onesCount/3; //number of ones in a single part\n        \n        //let\'s count trailing zeros in the latest part\n        for(k=len-1;arr[k]!=1;k--);\n        int trailingZeroesCount = len-1-k;\n        \n        //find beginning of the first part\n        l = findBeg(0, partOnesCount, trailingZeroesCount, arr);\n        if(l==-1)\n            return fail;\n\n        //find beginning of the second part\n        m = findBeg(l, partOnesCount, trailingZeroesCount, arr);\n        if(m==-1)\n            return fail;      \n        \n        for(i=--l,j=--m,k=len-1;i>=0 && j>l && k > m; i--,j--,k--)\n            if(arr[i]!=arr[j] || arr[j]!=arr[k]) //check item by item in all tree parts, that exact sequence should be the same in all tree parts\n                return fail;    \n\n        return new int[]{l,m+1};\n    }\n    \n    private int findBeg(int i, int partOnesCount, int trailingZeroesCount, int[] arr){\n        //shift i to the right by counting ones\n        for(;partOnesCount!=0;i++)\n            partOnesCount-=arr[i];\n        \n        //shift i to the right by counting trailing zeros\n        for(;trailingZeroesCount>0;i++, trailingZeroesCount--)\n            if(arr[i]!=0) //if we face non-zero value in trailing zeros area, the return error\n                return -1;   \n        \n        return i; //return potential beginning of the binary representation\n    }\n```\n\noriginal version : \n```\n    public int[] threeEqualParts(int[] arr) {\n        int len=arr.length, onesCount=0;\n        int[] fail = new int[]{-1,-1};  //error case return\n      \n        //every part of tree may have a variable number of zeros due to leading zeros, while\n        //number of ones should be the same in all parts;\n        //let\'s count overall number of ones\n        for(int a : arr)  \n            onesCount+=a;\n        \n        //if overall number of ones can\'t be divided equally between all three parts, then we return error\n        if(onesCount%3!=0 )\n            return fail;\n        \n        //in case of absence of ones, let\'s return any possible combination\n        if(onesCount==0)\n            return new int[]{0,2};\n\n        int i,j,k;\n        int partOnesCount =onesCount/3; //number of ones in a single part\n        \n        //let\'s count trailing zeros in the latest part\n        for(k=len-1;arr[k]!=1;k--);\n        int trailingZeroesCount = len-1-k;\n        \n        //shift i to the right by counting ones\n        int leftOnesCount = partOnesCount;\n        for(i=0;leftOnesCount!=0;i++)\n            leftOnesCount-=arr[i];\n        \n        //shift i to the right by counting trailing zeros\n        int leftTrailingZeros = trailingZeroesCount;\n        for(;leftTrailingZeros>0;i++, leftTrailingZeros--)\n            if(arr[i]!=0) //if we face non-zero value in trailing zeros area, the return error\n                return fail;\n        \n        int l = i-1, m=i;\n        //do the same with the middle part\n        int middleOnesCount = onesCount/3;\n        for(;middleOnesCount!=0;m++)\n            middleOnesCount-=arr[m];\n        \n        int middleTrailingZeros = trailingZeroesCount;\n        for(;middleTrailingZeros>0;m++, middleTrailingZeros--)\n            if(arr[m]!=0)\n                return fail;        \n        \n        m--; i = l; j = m; k = len-1;\n        while(i>=0 && j>l && k > m){\n            if(arr[i]!=arr[j] || arr[j]!=arr[k]) //check item by item, that exact sequence is the same in all tree parts\n                return fail;    \n            \n            i--; j--; k--;\n        }\n        return new int[]{l,m+1};\n    }\n```
[]