Java Solution with detailed Comments & Examples
\nclass Solution {\n    public int[] threeEqualParts(int[] arr) {\n        int ones = 0;\n        for (int i : arr) if (i == 1) ones++;\n\n\t\t/**\n\t\t * The f
```\nclass Solution {\n    public int[] threeEqualParts(int[] arr) {\n        int ones = 0;\n        for (int i : arr) if (i == 1) ones++;\n\n\t\t/**\n\t\t * The first base case is a hardcoded case when there are only zeros in the array. \n\t\t * Since the array size is at least 3 in the case of only zeros there are still available to cut the array and get three equal binary numbers. \n\t\t * e.g. [0, 0, 0] we can devide into three parts |0, 0, 0| and those numbers are correct binary numbers. \n\t\t * e.g. [0, 0, 0, 0, 0, ...] we can devide into three parts |0, 0, 0...| and those numbers are correct binary numbers. \n\t\t\n\t\t * arr = [0, 0, 0, 0, 0, ...]\n\t\t * ind = [0, 1, 2, 3, 4]\n         * i = 0 and j = 2 because first part is 0 - 0(0, i) indexes, second part is 1 - 1(i + 1, j - 1) indexes and third part is 2 - 2(j, n - 1) indexes\n\t\t\n\t\t * So taking into consideration above answer [0, 2] is the first correct answer that we can get in the case of only zeros. \n\t\t*/\n        if (ones == 0) return new int[]{0, 2};\n\t\t\n\t\t/**\n\t\t * If there are ones in an array they should be dividable on 3. \n\t\t * This is because we need to divide the array into three parts \n\t\t * and each part should have the same amount of ones \n\t\t * in the case of binary numbers to be equal\n\t\t*/\n        if (ones % 3 != 0) return new int[]{-1, -1};\n\n\t\t/**\n\t\t* This is the most trickier part of this solution.\n\t\t*  Basically what we are doing here is we are looking for the first occurrence of \'1\' for each chunk. \n\t\t*  Let\'s take an example: arr = [0, 1, 1, 0, | 0, 0, 1, 1, 0, | 1, 1, 0]\n\n\t\t* Since the count of ones is 6 and 6 / 3 = 2 it means that after every +2 index we are standing on the next chunk. 0 +, 2 +, 4 + ... \n\t\t* Therefore:  \n\t\t* First occurrence of \'1\' for the first chunk is on the index of 1\n\t\t* First occurrence of \'1\' for the second chunk is on the index of 6\n\t\t* First occurrence of \'1\' for the third chunk is on the index of 9\n\t\t*/\n        int point1 = 0, point2 = 0, point3 = 0;\n        int unit = ones / 3;\n        int oneCounter = 0;\n        for (int i = 0; i < arr.length; i++) {\n            if (arr[i] == 1) {\n                if (oneCounter == 0) point1 = i;\n                else if (oneCounter == unit) point2 = i;\n                else if (oneCounter == 2 * unit) point3 = i;\n\n                oneCounter++;\n            }\n        }\n\n\t\t/**\n\t\t* The last part is pretty straightforward. \n\t\t* We just need to start all pointers from the first occurrences of \'1\' and move three of them simultaneously to the right. \n\t\t* As we know binary numbers are equals if all of their bits are equal. Otherwise we return {-1, -1}\n\t\t*/\n        while (point3 < arr.length) {\n            if (arr[point1] != arr[point2] || arr[point2] != arr[point3]) return new int[]{-1, -1};\n\n            point1++;\n            point2++;\n            point3++;\n        }\n\n        return new int[]{point1 - 1, point2};\n    }\n}\n```
['Java']