anyone help me to figure out what potential case or base case mistake i had done so this giving me wrong answer.
following input
10 2
1 0 0 1 0 1 0 1 0 1
and correct output for following input
10 3
1 0 0 1 0 1 0 1 0 1
anyone help me to figure out what potential case or base case mistake i had done so this giving me wrong answer.
following input
10 2
1 0 0 1 0 1 0 1 0 1
and correct output for following input
10 3
1 0 0 1 0 1 0 1 0 1
check if your process is somehow same or not :
An Efficient Solution can solve the problem in O(n) time and O(1) space. The idea is to use Sliding Window for the given array. The solution is taken from here. Let us use a window covering from index wL to index wR. Let the number of zeros inside the window be zeroCount. We maintain the window with at most m zeros inside.
The main steps are:
While zeroCount is no more than m: expand the window to the right (wR++) and update the count zeroCount.
While zeroCount exceeds m, shrink the window from left (wL++), update zeroCount;
Update the widest window along the way. The positions of output zeros are inside the best window.
it’s okay i will optimization it my memoization.
i am try to think recursively.
plz help me to figure out what potential state or base case
i am missing ??
i don’t think this can be solved using memoization. And your Brute force sol won’t work here.
it’s alright
but at least help me to print only maximum length of subarray possible with the with operation given in question.
i trying to thinking recursively.
i want to figure out recursive solution for this case.
it does not matter accepted or not.
so plz help me.
help me first two test cases fail.
have a look where you are going wrong
i am unable to figure out.
please correct my recursive solution.
whenever you want me to find mistake in your code. please explain your logic !st because its very difficult to 1st read your code and then find mistakes.
i had explained code through documentations.
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.