Min Ops Binary Array to One

You are given a binary array nums (0s and 1s). In one operation, select three consecutive elements and flip all of them (0→1, 1→0). Return the minimum operations to make all elements 1, or -1 if impossible.

Examples
Input: [0,1,1,1,0,0]
Output: 3
Hints

Min Ops Binary Array to One

You are given a binary array nums (0s and 1s). In one operation, select three consecutive elements and flip all of them (0→1, 1→0). Return the minimum operations to make all elements 1, or -1 if impossible.