C++ Easy to Understand O(n)
If we can divide the number of 1s into 3 equal parts, we can just check the three parts for equality.  Dividing 1s into 3 partitions and checking for equality i
If we can divide the number of 1s into 3 equal parts, we can just check the three parts for equality. 
Dividing 1s into 3 partitions and checking for equality is a necessary and sufficient condition for the answer.
We need to take care of 0s only in the third partition because they will be trailing zeros always and will add to the third binary number representation always.
As long as first and second partition have the same number of trailing zeros as the third representation, we have a solution. We do not care about any other zeros in the first and second partition because trailing zeros of first can add to leading zeros of second and trailing zeros of second can add to leading zeros of third.

```
class Solution {
public:
    vector<int> threeEqualParts(vector<int>& A) {
        int num1s=0;
        for(int i:A) {
            if(i==1)
                num1s++;
        }
        if(num1s%3!=0)
            return {-1,-1};
        if(num1s==0)
            return {0,A.size()-1};
        int c=num1s/3;
        vector<int> nums(3,0);
        int count=0;
        for(int i=0;i<A.size();i++) {
            //If this is the start of the next binary representation(0 or 1 or 2 in vector nums)
            if(A[i]==1) {
                if(count%c==0) {
                    nums[count/c]=i;  //assign current index to nums[0,1,2]
                }
                count++;
            } 
        }
        //Every other representation should follow Last representation 
        while(nums[2]!=A.size()) {   
            if(A[nums[0]]!=A[nums[1]] || A[nums[0]]!=A[nums[2]])
                return {-1,-1};
            nums[0]++;
            nums[1]++;
            nums[2]++;
        }
        return {nums[0]-1, nums[1]};
    }
};
```
[]