Given a binary array, convert all the elements to zero Array (array with only zeros) in minimum number of steps
In one step we can choose any 2 adjacent elements and flip them together, or you can choose the last or first element and flip that particular element alone.
Input : N ( 1 <= N <= 1e5) Array elements ( 0 <= a[i] <= 1)
Output : Minimum number of steps to convert the binary array to all zeros
Sample : [1,0,1] Anwer is 2 ( one possible way is choose the second and third elements, flip them and then choose the first and second elements and flip them)
Can anyone help me solve this?