Python O(N) time /O(1) space
The idea is to count the trailing zero of the last session(must be counted)\nAs the leading zero can be ignored, we can just make sure that each session will ha
The idea is to count the trailing zero of the last session(must be counted)\nAs the leading zero can be ignored, we can just make sure that each session will have enough trailing zeros.\n\nLeading zeros will be ignored automatically by accu sum\n```\nclass Solution:\n    def threeEqualParts(self, arr: List[int]) -> List[int]:\n        one_count = sum(arr)\n        \n        if one_count % 3 != 0: return [-1, -1]\n        if one_count == 0: return [0, len(arr)-1]\n        \n        session_one_count = one_count // 3\n        session_trailing_zero = 0 # padding for each session\n        for i in range(len(arr)-1, -1, -1):\n            if arr[i] == 0:\n                session_trailing_zero += 1\n            else:\n                break\n        \n        last_accu = -1\n        curr_count = 0\n        curr_accu = 0\n        session_id = []\n        \n        i = 0\n        while(i < len(arr)):\n            curr_count += arr[i]\n            curr_accu = curr_accu * 2 + arr[i]\n            i += 1\n            if curr_count == session_one_count:\n                curr_trailing = 0\n                while(i < len(arr) and curr_trailing < session_trailing_zero):\n                    # find trailing zeros\n                    curr = arr[i]\n                    if curr == 0:\n                        curr_trailing += 1\n                        i += 1\n                    else:\n                        return [-1, -1] # not enough trailing zeros\n                    \n                if (last_accu != -1) and (curr_accu != last_accu):\n                    return [-1, -1]\n                \n\t\t\t\t# reset\n                last_accu = curr_accu\n                session_id.append(i)\n                curr_count = 0\n                curr_accu = 0\n        \n        return [session_id[0]-1, session_id[1]]\n```
[]