5. Longest Palindromic Substring

class Solution {
    public String longestPalindrome(String s) {
        if(s.length()<=1)
            return s;
        String zz = "";
        int ll = 0;
        int len = s.length();
        //0   1   2   3   4   5 
        //b , a , b , b , a , b
        //0 1 2 3 4 5 6 7 8 9 10
        for(int i=0;i<=2*len-2;i++){
            int tmp = (i%2==0)?1:0;
            for(int j=i/2;j>=0&&i-jll){
                        ll = tmp;
                        zz = s.substring(j, i-j+1);
                    }
                }else{
                    break;
                }
            }
        }   
        return zz;
    }
}

你可能感兴趣的:(5. Longest Palindromic Substring)