[C++] O(n) time, O(n) space,  easy to implement
Store every 1\'s position, easy to know the first 1\'s position of three parts as [x, y, z].\nThen verify three parts whether equal.\n\n\nclass Solution {\npubl
Store every 1\'s position, easy to know the first 1\'s position of three parts as [x, y, z].\nThen verify three parts whether equal.\n\n```\nclass Solution {\npublic:\nvector<int> threeEqualParts(vector<int>& v) {\n  int n = v.size();\n  vector<int> ones;\n  for (int i = 0; i < n; ++i) if (v[i]) ones.push_back(i);\n  int cnt = ones.size();\n  if (!cnt) return {0, n - 1};\n  if (cnt % 3) return {-1, -1};\n  int x = ones[0], y = ones[cnt/3], z = ones[cnt/3*2];\n  while (z < n && v[x] == v[y] && v[x] == v[z]) ++x, ++y, ++z;\n  if (z == n) return {x-1, y};\n  return {-1, -1};\n}\n};\n```
[]