✅✅Three Equal Parts || Python || Logic Building
Key obseration is that three parts must have same number and pattern of 1s except the leading 0s part. \nMy idea is to:\n\n1.  Count no. of ones, simply taking 
Key obseration is that three parts must have same number and pattern of 1s except the leading 0s part. \nMy idea is to:\n\n1.  Count no. of ones, simply taking sum. (if sum%3!=0 return [-1,-1])\n2.  Search from right side to left, until we found sum/3 of 1s. This index defines the pattern of 1s.\n3.  From left, ignore leading 0s, and then match the pattern found in step 2, to get the first EndIndex.\n4.  Similary, do another matching to found second EndIndex.\n\n```\nclass Solution:\n    def threeEqualParts(self, arr: List[int]) -> List[int]:\n        n=len(arr)\n        x=sum(arr)  #gives no. of 1s\n        if x==0:\n            return [0,2]\n        elif x%3!=0:\n            return [-1,-1]\n        \n        # finding index of starting 1 of third string\n        idx3=0\n        count=0\n        for i in range(n-1,-1,-1):\n            if arr[i]==1:\n                count+=1\n                if count==x//3:\n                    idx3=i\n                    break\n        \n        idx1=endIdx(arr,0,idx3)\n        if idx1<0:\n            return [-1,-1]\n        \n        idx2=endIdx(arr,idx1+1,idx3)\n        if idx2<0:\n            return [-1,-1]\n        \n        return [idx1,idx2+1]\n    \n#  here, idx3 is index of pattern to compare to.\n#  return endIdx of start pattern that matches idx3 side.\ndef endIdx(arr, start, idx3):\n    while arr[start]==0:\n        start+=1\n    while idx3<len(arr):\n        if arr[start]!=arr[idx3]:\n            return -1\n        start+=1\n        idx3+=1\n    return start-1\n```\n*If case of any doubt or suggestion, do comment.*\n\n***Happy Coding* :)**\n
[]