LEBOMBS Please verify

/* package codechef; // don’t place package name! */

import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String[] args) throws Exception
{BufferedReader bf=new BufferedReader(new InputStreamReader(System.in));
try{
int t=Integer.parseInt(bf.readLine());

	while(t-->0){
	    int n=Integer.parseInt(bf.readLine());
	   String s=bf.readLine();
	   int count=0;
	  boolean v=true;
	 
	   for(int i=1;i<s.length()-1;i++) {
	     
		   if(s.charAt(i)=='1'){
			   v=false;
		   }if(i>=1&&s.charAt(i-1)=='1') {
			   v=false;
		   }if(i<s.length()&&(s.charAt(i+1)=='1')) {
			   v=false;
		   }
		   if(v==true) {
			   count+=1;
		   }else {
			   v=true;
		   }
		   
	   }
	   if(s.charAt(0)=='0'&&s.charAt(1)=='0') {
		   count++;
	   }if(s.charAt(s.length()-1)=='0'&&s.charAt(s.length()-2)=='0') {
		   count++;
	   }
	   System.out.print(count);		   
}


}catch(Exception e) {
	return ;
}
}

}

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Edit:

Got bored waiting :slight_smile: Consider the test input:

1
1
0

and read this post.

2 Likes

Could you please attach the problem and/or solution link please
:upside_down_face:

1 Like