@@ -0,0 +1,1718 @@
+package leetcode;%0A%0A/**%0A * https://oj.leetcode.com/problems/longest-palindromic-substring/%0A */%0Apublic class Problem5 %7B%0A    public String longestPalindrome(String s) %7B%0A        if (s.length() == 1) %7B%0A            return s;%0A        %7D%0A        String longest = %22%22;%0A        char%5B%5D chars = s.toCharArray();%0A        for (int i = 0; i %3C chars.length; i++) %7B%0A            String p = palindrome(chars, i, true);%0A            if (p.length() %3E longest.length()) %7B%0A                longest = p;%0A            %7D%0A            p = palindrome(chars, i, false);%0A            if (p.length() %3E longest.length()) %7B%0A                longest = p;%0A            %7D%0A        %7D%0A        return longest;%0A    %7D%0A    %0A    private String palindrome(char%5B%5D chars, int idx, boolean even) %7B%0A        int left = idx;%0A        int right = idx;%0A        if (!even) %7B%0A            if (idx-1 %3E= 0 && idx+1 %3C chars.length && chars%5Bidx-1%5D == chars%5Bidx+1%5D) %7B%0A                left--;%0A                right++;%0A            %7D else if (idx+1 %3C chars.length && chars%5Bidx%5D == chars%5Bidx+1%5D) %7B%0A                right++;%0A            %7D else %7B%0A                return %22%22;%0A            %7D%0A        %7D else %7B%0A            if (idx+1 %3C chars.length && chars%5Bidx%5D == chars%5Bidx+1%5D) %7B%0A                right++;%0A            %7D else if (idx-1 %3E= 0 && idx+1 %3C chars.length && chars%5Bidx-1%5D == chars%5Bidx+1%5D) %7B%0A                left--;%0A                right++;%0A            %7D else %7B%0A                return %22%22;%0A            %7D%0A        %7D%0A        while (left %3E= 0 && right %3C chars.length) %7B%0A            if (chars%5Bleft%5D != chars%5Bright%5D) %7B%0A                break;%0A            %7D%0A            left--;%0A            right++;%0A        %7D%0A        left++;%0A        right--;%0A        return new String(chars, left, right-left+1);%0A    %7D%0A%7D%0A

Solve problem 5