NEED HELP FOR DEBUGGING

I am trying to solve SNELECT problem. It is working fine in my pc for all possible test cases present in question and also which i could think. But it is still showing runtime error(NZEC) during submission.
MY CODE:

import java.io.*;
import java.util.*;
class RIPsnakes
{
public static void main(String args[])throws IOException
{
  
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  int T=Integer.parseInt(br.readLine());
  for(int j=1;j<=T;j++){
  String a=br.readLine();
  char []A=a.toCharArray();
  int snakes=0; int mongoose=0;

 for(int i=0;i<A.length;i++){if(A[i]=='s'){snakes++;  }else{mongoose++;  } } 
  
  for(int i=0; i<A.length;i++)
  {if(A[i]=='m'){
      if(i==0){if(A[1]=='s'){snakes--; A[1]='_' ;} continue;}
     else if(i==A.length-1){if(A[i-1]=='s'){snakes--; A[i-1]='_';} break;}
     else if(A[i-1]=='s'){snakes--; A[i-1]='_'; continue;}
     else if(A[i+1]=='s'){snakes--; A[i+1]='_';  continue;}
    
    }
  
}
if(snakes>mongoose){System.out.println("snakes");}  
else if(snakes==mongoose){System.out.println("tie");}
else { System.out.println("mongooses");     }}}}
if(i==0){if(A[1]=='s'){snakes--; A[1]='_' ;} continue;}

What if my input is of size 1? Like only ‘s’ and ‘m’? A[1] will not exist then and this should give you NZEC.

2 Likes

Try debugging on your own

You can do it mate!
This is the only way to improve

Though vijju123 has corrected your code

1 Like