Python3 O(n) solution
\nclass Solution:\n    def threeEqualParts(self, A: List[int]) -> List[int]:\n        """\n        1: (# of 1) mod 3 == 0\n        2: calculate n3 values (start
```\nclass Solution:\n    def threeEqualParts(self, A: List[int]) -> List[int]:\n        """\n        1: (# of 1) mod 3 == 0\n        2: calculate n3 values (start with 0, end to tail)\n        3. check if there exists n1, n2 == n3\n        """\n        if sum(A) % 3 != 0:\n            return [-1, -1]\n        \n        if sum(A) == 0:\n            return [0, len(A) - 1]\n        \n        tot = sum(A)\n        cnt = sum(A) // 3 * 2\n        n3 = 0\n        for i, n in enumerate(A):\n            if cnt > 0:\n                cnt -= n\n            else:\n                n3 = 2 * n3 + n\n        \n        n1 = 0\n        n2 = 0\n        i1 = None\n        i2 = None\n        for i, n in enumerate(A):\n            if n1 > n3 or n2 > n3:\n                return [-1, -1]\n            elif n1 == n3:\n                n2 = 2 * n2 + n\n            else:\n                n1 = 2 * n1 + n\n                \n            if n1 == n3 and i1 is None:\n                i1 = i\n            \n            if n2 == n3:\n                return [i1, i + 1]\n            \n        return [-1, -1]\n```
[]