c++, simple to follow, fast, solution. O(n) time, O(1) space. With description and comments
The problem requires the dividing the input string such that the binary values are equal, so the first thing to do is check that the number of 'bits' set is div
The problem requires the dividing the input string such that the binary values are equal, so the first thing to do is check that the number of 'bits' set is divisible by 3. If there are no set bits, then the answer is trivial and can be returned now.

If it is divisible by 3, we can relatively easily find the minimum total length of each partition by reading from the back. Why from the back? Well the number of trailing zeros is important, while the leading zeros not. For example, imagine each section has one bit set, an input string must finish with something like [..., 1], [..., 1, 0], [..., 1, 0, 0], ..., [..., 1, <_m_ zeros>]. Once we've encountered the required number of sets bits, we know the _mimimum_ (as there could be 0 or more _leading_ zeros) length of each partition.

From there, the final steps are straight forward.

1. Check that there is at least _m_ zeros before the next set bit is encountered (still reading backwards)
2. Keep moving left until the required number of set bits has been encountered, checking each bit matches the first partition
3. Check that there is at least _m_ zeros before the next set bit is encountered
4. Finally check the last partition matches with a simple `std::equal` (since we know what the distance between the first and last set bits)
5. If it all matches, return the partition indexes

Putting it all together in quite readable code, produces;

```cpp
  vector<int> threeEqualParts(vector<int>& A) {
    int total_set_bits = std::count(A.begin(), A.end(), 1);
    if (3 > A.size() || total_set_bits % 3) {
      return {-1, -1};
    }
    if (!total_set_bits) {
      return {0, A.size() - 1};
    }

    // Number of set bits for each partition
    int partition_set_bits = total_set_bits / 3;

    // Work from back to front as we need to check trailing zeros and not leading zeros
    auto first = std::find(A.rbegin(), A.rend(), 1);

    // Number of 0s that must finish each section
    int trailing_zeros = first - A.rbegin();

    // Jump to the last 1 in the current partition
    auto tmp = first;
    for (int i = 1; i < partition_set_bits; ++i) {
      tmp = std::find(tmp + 1, A.rend(), 1);
    }

    // Distance between the first set bit and the last for each partition
    int distance = tmp - first;

    // Check that there is enough trailing zeros in the middle section
    auto middle = std::find(++tmp, A.rend(), 1);
    if (middle - tmp < trailing_zeros) {
      return {-1, -1};
    }

    // Check the middle partition matches while advancing to the last 1 in the middle
    tmp = middle;
    for (int i = 0; i < distance; ++i) {
      if (*(first + i) != *tmp++) {
        return {-1, -1};
      }
    }

    // Check that there is enough trailing zeros in the last section
    auto last = std::find(++tmp, A.rend(), 1);
    if (last - tmp < trailing_zeros) {
      return {-1, -1};
    }

    // Finally check the last section matches
    if (A.rend() - last >= distance && !std::equal(middle, middle + distance, last, last + distance)) {
       return {-1, -1};
    }

    // Finally change the reverse iterators back into a forward index
    int break1 = last.base() - A.begin() + trailing_zeros - 1;
    int break2 = middle.base() - A.begin() + trailing_zeros;
    return {break1, break2};
  }
```

[]