Here’s my code , works perfectly fine in my IDE like every other code which i write but i always always get NZEC error in at input point in code chef IDE.
I tried Scanner i got same result , i used BuffererReader i get same result . It has really become frustrating for me now as i am not able to submit most of the problems which i was solve correctly.
While when i checked solution , so many others have used int test with BufferedReader and they were able to submit the code.
I request someone to pls pls pls help me out.
Here’s my solution of code chef code -> Splitit
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final int test = Integer.parseInt(br.readLine());
for (int i = 0; i < test; i++) {
boolean check = false;
int N = Integer.parseInt(br.readLine());
String s = br.readLine();
for(int j = 0 ; j < N-2 ; j++){
for(int k = j+2 ; k < N ; k++){
StringBuilder stringBuilder = new StringBuilder(s);
String toAppend = stringBuilder.substring(j,k);
stringBuilder.replace(N-toAppend.length() , N , toAppend);
if(stringBuilder.toString().equals(s)){
check = true;
break;
}
}
if(check){
break;
}
}
if(check){
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
}