✅   Three Equal Parts || C++ Easy Solution || With Approach
APPROACH\n1. Store every 1\'s position in a vector.\n2. It is easy to know the first 1\'s position of three parts as [x, y, z].\n3. Then verify three parts whet
# **APPROACH**\n1. Store every 1\'s position in a vector.\n2. It is easy to know the first 1\'s position of three parts as [x, y, z].\n3. Then verify three parts whether equal\n\n***NOTE:***\n* If in cases where number of ones are not a multiple of 3, there will be no case of equal parts so return {-1,-1}\n```\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) \n    {\n        int n = arr.size() ;\n        vector<int> one ;\n        for(int i = 0 ; i < n ; i++)\n        {\n            if(arr[i])\n            {\n                one.push_back(i) ;\n            }\n        }\n        int cnt = one.size() ;\n        if(cnt == 0)\n        {\n            return {0 , n - 1} ;\n        }\n        if(cnt%3)          //IF NUMBER OF ONES IS NOT A MULTIPLE OF 3\n        {\n            return {-1 , -1} ;\n        }\n        int s = one[0] , t = one[cnt/3] , u = one[(cnt/3)*2] ;\n        while(u < n && arr[s] == arr[t] && arr[s] == arr[u])\n        {\n            s++ ;\n            t++ ;\n            u++ ;\n        }\n        if(u == n)\n        {\n            return {s - 1 , t} ;\n        }\n        return {-1 , -1} ;\n    }\n};\n```\n**Time Complexity:  O(n)**\n**Space Complexity:  O(n)**\n# **Update:**\nThis is the general approach once we know that number of ones are a multiple of three -->\nWe can form intervals for `s , t & u` let\'s say, `[i1, j1], [i2, j2], [i3, j3]` \n__If there is only 3 ones, then this interval length will be one__\nSo the **zeroes after "one, on the position of u"** *let\'s assume z* , must be included in each part (i.e. in s & t)\nMaking the new intervals, `[i1, j1+z] & [i2, j2+z]` for s & t respectively\nIf all this is actually possible, then the final answer is **[j1+z , j2+z+1].**\nHope this helps
['C']