Longest subsegment of β€˜1’s formed by changing at most k β€˜0’s

link:-


why its giving wrong ans:

@riprogerdep
You’ve sent wrong code link

sorry this is the correct link

@riprogerdep

bro i have refered that plz look my code its very small as the original solution but not getting accepted

@riprogerdep
Your code is failing the most basic cases

Q : 1 0
0
A : 0
0

Q : 7 0
0 1 0 0 0 1 0
A : 1
0 1 0 0 0 1 0

I can only fix issues with the code. Your logic was incorrect. I would end up rewriting the entire thing. That’s why I sent you the gfg solution.

the cases you gave my code is working on that …in this platform 2 out 5 cases are coming correct and i have checked the gfg also…i thing printing is the issue pl look into it

my entire code is same as the gfg one except for loop where i used while

@riprogerdep

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.