Need help for runtime error


  • -2
    C

    char* cpy(char* s, int length){
    char* ans;
    int i;
    for(i=0;i<length;i++){
    (ans+i)=(s+i);
    }
    return ans;
    }

    char* longestPalindrome(char* s) {
    if((s+1)=='\0') return s;
    int i=0, max_length=1000;
    int j=0;
    char
    left;
    char* right;
    char* max;
    while((s+i+2)||(s+i+1)){
    left=s+i;
    right=s+i+1;
    if(left==right){
    while(
    (left-j)==
    (right+j)&&(right+j)!='\0'&&j<=i){
    j++;
    }
    max=cpy(left-j+1, 2
    (j-1));
    return max;
    }
    if(left==(right+1)){
    while((left-j)==(right+j+1)&&(right+j+1)!='\0'&&j<=i){
    j++;
    }
    max=cpy(left-j+1, 2
    (j-1)+1);
    return max;
    }
    i++;
    }

    }


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.