Why this code error?


  • 0
    H

    public class Solution {
    public String longestPalindrome(String s) {
    int i,j,sign;
    i=0;
    j=s.length()-1;
    int k=j;
    sign=0;
    int start=0,end=0;
    if(s.length()==1) return s;
    while(i!=k){
    if(s.charAt(i)!= s.charAt(k)){
    i++;
    k--;
    sign++;
    }else{
    if(sign%2==0){
    i++;
    start=i;
    end=k;
    }else{
    k--;
    start=i;
    end=k;
    }
    }
    }
    return s.substring(start,end);
    }
    }


Log in to reply
 

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