https://www.codechef.com/submit/LAPIN

https://www.codechef.com/submit/LAPIN
Someone please explain what is wrong with my output.
/* 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 java.lang.Exception
{
// your codbnsjkjfnkfnjkdsfnksdne goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t–>0)
{
String s=sc.next();
s=s.toLowerCase();
int l=s.length();
if((s.substring(0,l/2)).equals(s.substring(l/2+1,l)))
{
System.out.println(“YES”);
}
else if((s.substring(0,(l/2-1))).equals(s.substring(l/2+1,l)))
{
System.out.println(“YES”);
}
else
{
System.out.println(“NO”);
}
}
}
}

comment your code

/* 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 java.lang.Exception
{
// your codbnsjkjfnkfnjkdsfnksdne goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t–>0)
{
String s=sc.next();
s=s.toLowerCase();
int l=s.length();
if((s.substring(0,l/2)).equals(s.substring(l/2+1,l)))
{
System.out.println(“YES”);
}
else if((s.substring(0,(l/2-1))).equals(s.substring(l/2+1,l)))
{
System.out.println(“YES”);
}
else
{
System.out.println(“NO”);
}
}
}
}

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

2 Likes

thank you, am trying to rectify it now.

1 Like