Golang & C++ solution
go\nfunc threeEqualParts(arr []int) []int {\n\t// remove all leading zeros if 1 exist\n\tremovedLeadingZero := 0\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[
```go\nfunc threeEqualParts(arr []int) []int {\n\t// remove all leading zeros if 1 exist\n\tremovedLeadingZero := 0\n\tfor i := 0; i < len(arr); i++ {\n\t\tif arr[i] == 1 {\n\t\t\tremovedLeadingZero = i\n\t\t\tarr = arr[i:]\n\t\t\tbreak\n\t\t}\n\t}\n\t// valid check\n\tif len(arr) < 3 {\n\t\treturn []int{-1, -1}\n\t}\n\t// arr[0] equal to 0 means all value in arr is 0\n\tif arr[0] == 0 {\n\t\treturn []int{0, 2}\n\t}\n\t// first non zero index from current to last index\n\tfirstNonZero := make([]int, len(arr))\n\tnonZeroIndex := math.MaxInt32\n\tfor i := len(arr) - 1; i >= 0; i-- {\n\t\tif arr[i] == 1 {\n\t\t\tnonZeroIndex = i\n\t\t}\n\t\tfirstNonZero[i] = nonZeroIndex\n\t}\nloop:\n\tfor end1 := 0; end1 < len(arr)-2; end1++ {\n\t\tsize := end1 + 1\n\t\tend2 := firstNonZero[end1+1] + end1\n\t\tif end2 >= len(arr)-1 {\n\t\t\tcontinue\n\t\t}\n\t\tend3 := firstNonZero[end2+1] + end1\n\t\tif end3 != len(arr)-1 {\n\t\t\tcontinue\n\t\t}\n\t\tfor i := 0; i < size; i++ {\n\t\t\tif arr[end1-i] != arr[end2-i] {\n\t\t\t\tcontinue loop\n\t\t\t}\n\t\t\tif arr[end1-i] != arr[end3-i] {\n\t\t\t\tcontinue loop\n\t\t\t}\n\t\t}\n\t\treturn []int{end1 + removedLeadingZero, end2 + 1 + removedLeadingZero}\n\t}\n\treturn []int{-1, -1}\n}\n```\n\n```c++\nclass Solution {\npublic:\n    vector<int> threeEqualParts(vector<int>& arr) {\n        int sizeOfOne = 0;\n        for (auto &i : arr) {\n            if (i == 1) {\n                sizeOfOne++;\n            }\n        }\n        if (sizeOfOne % 3 != 0) {\n            return vector<int>{-1, -1};\n        }\n        if (sizeOfOne == 0) {\n            return vector<int>{0, 2};\n        }\n        int currentSizeOfOne = 0;\n        int end1 = 0;\n        int end2 = 0;\n        int end3 = 0;\n        int prefixZero = -1;\n        for (std::vector<int>::size_type i = 0; i < arr.size(); i++) {\n            if (arr[i] == 1) {\n                currentSizeOfOne++;\n                if (prefixZero == -1) {\n                    prefixZero = i;\n                }\n                if (currentSizeOfOne == sizeOfOne/3) {\n                    end1 = i;\n                }\n                if (currentSizeOfOne == sizeOfOne/3*2) {\n                    end2 = i;\n                }\n                if (currentSizeOfOne == sizeOfOne) {\n                    end3 = i;\n                }\n            }\n        }\n        int suffixZero = static_cast<int>(arr.size() - 1) - end3;\n        end1 += suffixZero;\n        end2 += suffixZero;\n        end3 += suffixZero;\n        for (auto i = 0; i <= end1-prefixZero; i++) {\n            if (arr[end1-i] != arr[end2-i] || arr[end1-i] != arr[end3-i]) {\n                return vector<int>{-1, -1};\n            }\n        }\n        return vector<int>{end1, end2+1};\n    }\n};\n```
['C', 'Go']