I think there is problem with complier

#include<bits/stdc++.h>
using namespace std;

int ans(int n,vector&arr,int k){
if(n==0){
return 0;
}

int l = 0;
int count_0 = 0;
int maximum = 0;

for(int i=0;i<n;i++){
if(arr[i]==1){
continue;
}

 if(arr[i]==0){
	 count_0++;
 }

 while(count_0>k){
	 if(arr[l]==0){
		 count_0--;
		 l++;
	 }
 }

 maximum = max(maximum,i-l+1);

}

return maximum;

}

int main() {
int n;
cin>>n;
int k;
cin>>k;
vectorarr;
for(int i=0;i<n;i++){
int x;
cin>>x;
arr.push_back(x);

}

cout << ans(n,arr,k) << endl;

}

@Mohitpandey29
hello Mohit,
what issue u are facing?

@Mohitpandey29
image

a) write l++ outside ur if statement otherwise it will run in inifinite loop
b) check output format u need to print modified array as well

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.