| 
 | 
back to boardWHY WA ON TEST #2??? I CAN'T UNDERSTAND I think my code is correct.. what's the tricky input? or what's wrong with my code? I just made a O(n^2) algorithm to search here is my code: #include <stdio.h> #include <string.h> char a[1003],b[1003];   int main(){   int i,j,u,v,l,ind,res=0,tmp;   scanf("%s",&a);   l=strlen(a);   for(i=0;i<l;i++)     b[i]=a[l-1-i];   for(i=0;i<l;i++)     for(j=0;j<l;j++)       if(a[i]==b[j]){          tmp=0;          for(u=i+1,v=j+1;v<l;u++,v++){             if(a[u]==b[v])               tmp++;             else               break;          }          if(tmp>=res){            res=tmp;            ind=i;          }      }    for(i=ind;i<=ind+res;i++)       printf("%c",a[i]);    printf("\n");   return 0; } If there are several, choose the leftmost; a test for you (+) AB   your answer: B correct answer: A    |  
  | 
|