Three test case are not passed what is wrong

your code is giving the correct size of maximum continous 1`s in the array but the modified array is wrong

test case:
10 4
1 0 0 0 1 1 0 1 1 0
answer is 9 that is first 9 bits are 1 and the last bit is 0
ur code ouputs 9
1 0 1 1 1 1 1 1 1 1

You have done a great bit of deal , try modifying the code once by yourself, since its easier to update once u know were u lag.
in case u are unable to make it , ping me i`ll help u