I tried sliding window approach but stuck for last test case
My last test case failed
You can do it using queue or two pointer approach, keep track of the first zero encountered as soon as you encounter new zero check if count of zero from first to now is more than k or not, if count exceeds k move update first. In each step keep on updating the length.
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.