2 clean Python linear solutions
\nclass Solution:\n    def threeEqualParts(self, arr: List[int]) -> List[int]:\n        # count number of ones\n        ones = sum(arr)\n        if ones % 3 != 
```\nclass Solution:\n    def threeEqualParts(self, arr: List[int]) -> List[int]:\n        # count number of ones\n        ones = sum(arr)\n        if ones % 3 != 0:\n            return [-1, -1]\n        elif ones == 0:  # special case: all zeros\n            return [0, 2]\n        \n        # find the start index of each group of ones\n        c = 0\n        starts = []\n        for i, d in enumerate(arr):\n            if d == 1:\n                if c % (ones // 3) == 0:\n                    starts.append(i)\n                c += 1\n\n        # scan the groups in parallel to compare digits\n        i, j, k = starts\n        while k < len(arr):  # note that the last/rightmost group must include all digits till the end\n            if arr[i] == arr[j] == arr[k]:\n                i += 1\n                j += 1\n                k += 1\n            else:\n                return [-1, -1]\n        return [i-1, j]\n```\nRuntime: *O(n)*\nSpace: *O(1)*\n\n```\nclass Solution:\n    def threeEqualParts(self, arr: List[int]) -> List[int]:\n        # gather the indices of the ones\n        ones = [i for i, d in enumerate(arr) if d == 1]\n\n        if not ones:\n            return [0, 2]\n        elif len(ones) % 3 != 0:\n            return [-1, -1]\n\n        # get the start indices of the 3 groups\n        i, j, k = ones[0], ones[len(ones)//3], ones[len(ones)//3*2]\n\n        # calculate the size/length of what each group should be\n        length = len(arr) - k  # note that the last/rightmost group must include all digits till the end\n                               # so we know that the size of each group is `len(arr) - k` (where `k` is start of third group)\n\n        # compare the three groups\n        if arr[i:i+length] == arr[j:j+length] == arr[k:k+length]:\n            return [i+length-1, j+length]\n        \n        return [-1, -1]\n```\nRuntime: *O(n)*\nSpace: *O(n)*
['Python', 'Python3']