Time limit error

How can I optimize my code as I am facing TLE in one testcase. Kindly have a look.

This is another approach for the problem : https://ide.codingblocks.com/s/187255

hi
for your approach in https://ide.codingblocks.com/s/187255

this does not work for cases like
2 0
0
try and dry run that

for https://ide.codingblocks.com/s/187248
you are getting tle for when n is big like 15000
this was a sliding window type problem which will affected by 0 so there should be a check on zero it will fail for a case when there is a large input and multiple cases
https://ide.codingblocks.com/s/187417 refer to this

But 2 represents the size of the array. Therefore I am intended to give 2 inputs.
Thus this can’t be the valid input for the problem.
And for input like 2 0
0 0
The output should be 0 and 0 0
And I am getting the same answer from this code.

Can you tell me about this Sliding Window concept applied in the question. What’s the approach you are following in this code.

@mananaroramail your codes are going wrong for the large test cases .to tackle this we go for the two pointer sliding window technique,we consider a 2 pointers and a criteria that zeroes should be less than k and then moves the start pointer one step ahead until the criteria is no longer true, during which process, we also update best left best right and best length variable which records the max subarray length that satisfies the criteria.