Linear times, O(n) Solution in Python [clean]
\n# Github: Shantanugupta1118\n# DAY 60 of DAY 100\n# 927. Three Equal Parts  -  Leetcode/July\n# https://leetcode.com/problems/three-equal-parts/\n\n\nclass So
```\n# Github: Shantanugupta1118\n# DAY 60 of DAY 100\n# 927. Three Equal Parts  -  Leetcode/July\n# https://leetcode.com/problems/three-equal-parts/\n\n\nclass Solution:\n    def threeEqualParts(self, arr):\n        ans = [-1,-1]\n        numsOf1s = 0\n        for i in arr:\n            numsOf1s += i\n        if numsOf1s == 0:\n            return [0,2]\n        if numsOf1s%3 != 0:\n            return ans\n        \n        eachPart = numsOf1s//3\n        index0, index1, index2 = -1, -1, -1\n        numsOf1s = 0\n        for i in range(len(arr)):\n            if arr[i] == 1:\n                numsOf1s += 1\n                if numsOf1s == eachPart+1:\n                    index1 = i\n                elif numsOf1s == 2*eachPart+1:\n                    index2 = i\n                elif numsOf1s == 1:\n                    index0 = i\n        while index2 < len(arr):\n            if arr[index2] == arr[index0] and arr[index2] == arr[index1]:\n                index0 += 1\n                index1 += 1\n                index2 += 1\n            else:\n                return ans \n        return [index0-1, index1]\n```
['Python', 'Python3']