1 count problem

3out of 5 test cases gone wrong

@Learning_bunny when your updating max_s you also need to save the corresponding l and r because this is the case which we need to print, otherwise l an r are going to changes as you move in the array.

done that but now first test case is failing which is passing with the previous code???

@Learning_bunny initialize the β€˜al’ and β€˜ar’ variables with -1 because k can be zero also in that case we have to print the array as it is initially.

@Learning_bunny Also please mark the doubt as resolved if you are able to understand and solve the problem now.

then in place of max length of array we should print -1

No in that case it is still possible that there are some continuous 1 with doing any change, so just do the same process.

test case 0 and 1 are still wrong

@Learning_bunny https://ide.codingblocks.com/s/235185 this is your previous code which i modified please have a look at it and ask if you have any doubts in it.

Otherwise please mark this doubt as resolved.