scala solution.
\ndef findEndIdx(arr: Array[Int], i: Int, binary_value: String):Int = {\n        if(arr.drop(i).dropWhile(_==0).take(binary_value.length).foldLeft("")((b,a)=> a
```\ndef findEndIdx(arr: Array[Int], i: Int, binary_value: String):Int = {\n        if(arr.drop(i).dropWhile(_==0).take(binary_value.length).foldLeft("")((b,a)=> a + b) != binary_value) return -1\n        return arr.drop(i).takeWhile(_==0).length + i + binary_value.length\n      }\n      def threeEqualParts(arr: Array[Int]): Array[Int] = {\n        val cnt = arr.count(_ == 1)\n        val n = arr.length\n        if (cnt%3 !=0) return Array(-1,-1)\n        if(cnt == 0)  return Array(0,n - 1)\n        val idxThird  =arr.zipWithIndex.filter(n=> n._1 == 1).takeRight(cnt/3).take(1)(0)._2\n        val binary_value = arr.takeRight(n - idxThird).foldLeft("")((b,a)=>{a + b})\n        val res1 = findEndIdx(arr, 0, binary_value)\n        if (res1 < 0) return Array(-1,-1)\n        val res2 = findEndIdx(arr, res1, binary_value)\n        if (res2 < 0) return Array(-1,-1)\n        return Array(res1 - 1,res2)\n      }\n```
[]