javascript 90ms
\nvar threeEqualParts = function(A) {\n    const getOneCount = () => {\n        const oneCount = A.reduce((acc, bit) => bit == 1 ? acc + 1 : acc, 0)\n        if
```\nvar threeEqualParts = function(A) {\n    const getOneCount = () => {\n        const oneCount = A.reduce((acc, bit) => bit == 1 ? acc + 1 : acc, 0)\n        if(oneCount % 3 == 0) \n            return oneCount / 3\n        return -1\n    }\n\n    const getTail = oneCount => { \n        let zeroCount = 0, idx = A.length -1\n        let oneRemain = oneCount\n        while(oneRemain > 0) {\n            if(A[idx] == 1) {\n                oneRemain--\n            }\n            if(A[idx] == 0 && oneRemain == oneCount) {\n                zeroCount++\n            }\n            idx--\n        }\n        return {zeroCount, tailStart: idx + 1}\n    }\n\n    const getHead = (oneCount, zeroCount) => {\n        let idx = 0\n        while(oneCount > 0) {\n            if(A[idx] == 1)\n                oneCount--\n            idx++\n        }\n        if(zeroCount > 0) {\n            while(A[idx] == 0 && zeroCount > 0){\n                idx++\n                zeroCount--\n            }\n        }\n        return zeroCount == 0 ? idx-1 : -1\n    }\n\n    const getMiddle = (oneCount, headEnd, tailStart) => {\n        let idx = headEnd + 1\n        let tailIdx = tailStart\n        while(A[idx] != 1) idx++\n        while(idx < tailStart && A[idx] == A[tailIdx]) {\n            idx++\n            tailIdx++\n        }\n        if(tailIdx != A.length)\n            return -1\n        return idx\n\n    }\n\n    const oneCount = getOneCount()\n    if(oneCount == -1 || A.length < 3)\n        return [-1, -1]\n    if(oneCount == 0) return [0, A.length-1]\n    const {tailStart, zeroCount} = getTail(oneCount)\n    const headEnd = getHead(oneCount, zeroCount)\n    if(headEnd == -1)\n        return [-1, -1]\n    const middleEnd = getMiddle(oneCount, headEnd, tailStart)\n    if(middleEnd == -1)\n        return [-1, -1]\n    return [headEnd, middleEnd]\n};\n```
['JavaScript']