javascript, 84ms
Approximately 1.33N operations => O(N).\n\n\n/**\n * @param {number[]} arr\n * @return {number[]}\n */\nvar threeEqualParts = function (arr) {\n  const gaps = [
Approximately 1.33N operations => O(N).\n\n```\n/**\n * @param {number[]} arr\n * @return {number[]}\n */\nvar threeEqualParts = function (arr) {\n  const gaps = []\n  let head0s = 0\n  let prev\n  for (let p = 0; p < arr.length; p++) {\n    if (arr[p] === 1) {\n      if (prev !== undefined) {\n        gaps.push(p - prev)\n      }\n      prev = p\n    } else if (prev === undefined) {\n      head0s++\n    }\n  }\n  if (head0s === arr.length) {\n    return [0, 2]\n  }\n  if (gaps.length % 3 !== 2) {\n    return [-1, -1]\n  }\n  const groupLen = (gaps.length - 2) / 3\n  let groupSum = 0\n  for (let q = 0; q < groupLen; q++) {\n    if (\n      gaps[q] !== gaps[q + groupLen + 1] ||\n      gaps[q] !== gaps[q + 2 * groupLen + 2]\n    ) {\n      return [-1, -1]\n    }\n    groupSum += gaps[q]\n  }\n  const tail0s = arr.length -\n    head0s -\n    groupSum * 3 -\n    gaps[groupLen] -\n    gaps[2 * groupLen + 1] -\n    1\n  if (gaps[groupLen] - 1 < tail0s || gaps[2 * groupLen + 1] - 1 < tail0s) {\n    return [-1, -1]\n  }\n  const i = head0s + groupSum + tail0s\n  const j = i + gaps[groupLen] + groupSum + 1\n  return [i, j]\n}\n\n```
['JavaScript']