simple C soultion with detailed analysis
The core idea is:\n1. if we look from backward, the last element must be valid part of the 3-rd number.\n2. we can get how many \'1\' should be in a part by cou
The core idea is:\n1. if we look from backward, **the last element must be valid part of the 3-rd number.**\n2. we can get *how many \'1\' should be in a part* by **counting how many one in array** and divde it into 3\n3. if we get a fraction instead an integer, it must **not** equal.\n4. then we just **count how many 1 has seen** to get every part\'s start position\n5. compare 3 parts of the array to ensure they\'re equal.\n\n```\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* threeEqualParts(int* A, int ASize, int* returnSize){\n    int n,i;\n    int *r = (int *)malloc(sizeof(int)*2);\n    r[0]=r[1]=-1;\n    *returnSize = 2;\n    //count how many ones in array\n    for(n = i = 0; i < ASize; i++)\n    {\n        if(A[i])n++;\n    }\n    //if it\'s worth trying, it must contain equal ones of each\n    if(n && n % 3 == 0)\n    {\n        uint16_t d = 0; // length of a part\n        uint16_t q = 0; // length counter of a part and its forehead\n        uint16_t p=0; // counter of \'1\' has read\n        uint16_t s=0; // current position record pointer\n        uint16_t k[3]={0}; //begin positions of parts\n        //every part has this amount of \'1\'\n        n /= 3;\n        //loop from backward in order to count acutal part size first.\n        for(i = ASize - 1;i>=0;i--)\n        {\n            q++; // count how many chars gone though\n            if(A[i] && (++p % n == 0 || n == 1)) // if \'1\' then test if reached a point to do segment\n            {\n                k[s++]=i; //record and move pointer to next record\n                if(d == 0) d = ASize - i; //set corret length of a part\n                else if(d < n || d > q) return r; // incorret length found, immediate return\n                q = 0; // reset part char counter for next one\n            }\n        }\n        //detect unmatch pattern\n        for(i = 0; i < d; i++)\n        {\n            if(!((A+k[2])[i]==(A+k[0])[i] && (A+k[0])[i] == (A+k[1])[i]))return r;\n        }\n        //set position to first one\'s last char and second one\'s last char\n        r[0] = k[2]+d-1;\n        r[1] = k[1]+d;\n    }\n    else if(n == 0)\n    {\n        //wired, unwritten rule, even applies to empty input.\n        r[0]=0;\n        r[1]=ASize-1;\n    }\n    return r;\n}\n```
['C']