Help In LEBOMBS

#include
using namespace std;

int main() {
int test;
cin>>test;
while(test–){
int n,i;
cin>>n;
char a[n];
cin>>a;
for(i=0;i<=n-1;i++){
if(a[i]==49 ){
//a[i+1]=49;
a[i-1]=49;
a[i+1]=‘k’;
}
}
int count=0;
i=0;
while(a[i]!=’\0’){
if(a[i]==48){
count=count+1;
}
i++;
}
cout<<count<<endl;
}
return 0;
}

check this test case :
1
5 11001
Output will be: 0
you are updating the same string a[i+1] index by k , now for this example string is 11001 as 0 th index value is 1 so you are updating your string as 1k001. now as your string a[1] is k . It is not effecting building 2.
My solution: https://www.codechef.com/viewsolution/28047300

1 Like

thanks!!!

welcome :slight_smile:

1 Like