Swift solution
Count ones in arr\n2. If there is no ones in arr, then all parts are zeros\n3. Ones count must be multiple of three, else it is not possible to split arr into t
1. Count ones in `arr`\n2. If there is no ones in `arr`, then all parts are zeros\n3. Ones count must be multiple of three, else it is not possible to split `arr` into three parts\n4. Find first significant bit for each part in `arr`\n5. The last part ends at the end of `arr`, it has a reference length. Check that the length of the first two parts is not less than the reference one.\n6. Check the equality of the three parts\n\nTime complexity O(n), space complexity O(1)\n\nUpdate: simplified reduce, as [@Legonaftik](https://leetcode.com/Legonaftik/) suggested\n```\nclass Solution {\n    func threeEqualParts(_ arr: [Int]) -> [Int] {\n        let n = arr.count, ones = arr.reduce(0, +), partOnes = ones / 3\n        guard ones > 0 else { return [0, 2] } // all parts are zeros\n        guard ones % 3 == 0 else { return [-1, -1] } // it is not possible to split into three parts\n\n        var starts = [Int](repeating: -1, count: 3), runningOnes = 0\n        for i in 0..<n where arr[i] == 1 {\n            let part = runningOnes / partOnes // 0...2\n            if starts[part] == -1 {\n                starts[part] = i\n            }\n            runningOnes += 1\n        }\n\n        let len = n - starts[2]\n\n        guard starts[1] - starts[0] >= len && starts[2] - starts[1] >= len else { return [-1, -1] }\n\n        // check if three parts are equal\n        for l in 0..<len where arr[starts[0] + l] != arr[starts[1] + l] || arr[starts[0] + l] != arr[starts[2] + l] {\n            return [-1, -1]\n        }\n        \n        return [starts[0] + len - 1, starts[1] + len]\n    }\n}\n```
['Swift']