[Java] O(n) time; O(1) space (8 ms)
Check if there are enough number of ones for three parts (aka number of ones is a multiple of 3). Iterate the array from the tail and find the spot that marks t
1. Check if there are enough number of ones for three parts (aka number of ones is a multiple of 3).
2. Iterate the array from the tail and find the spot that marks the start of a binary number with n/3 1s (n is total number of ones).
3. Lets call the marker in step 2 "part3". We need to check to see if there are 2 more occurences of this part (part3 to end of array) between 0 and part3.
4. In order to lookup the part, start from the beginning of the array, ignoring all the leading zeros (as they don't contribute to the value), try to match with  the number formed by part3 - end. 
5. Repeat step 4 one more time, this time starting at the end of first match.
```
class Solution {
    public int[] threeEqualParts(int[] A) {
        int count = 0;
        for(int i : A){
            count = count+i;
        }
        if(count==0){
            return new int[]{0,A.length-1};
        }
        if(count%3!=0){
            return new int[]{-1,-1};
        }
        int part3 = A.length;
        int soFar = 0;
        while(soFar<count/3 && part3>-1){
            part3--;
            soFar += A[part3];            
        }
        int tracker = match(A, 0, part3);
        if(tracker==-1){
            return new int[]{-1, -1};
        }
        int end = match(A, tracker, part3);
        if(end==-1){
            return new int[]{-1, -1};
        }        
        return new int[]{tracker-1, end};
    }
    
    private int match(int[] A, int start, int ref){      
        while(A[start]==0){
            start++;
        }    
        while(ref < A.length){
            if(A[ref]!=A[start]){
                return -1;
            }
            ref++;
            start++;
        }
        return start;
    }
}
```
[]