@@ -0,0 +1,1036 @@
+package algorithm.string%0A%0A/**%0A * @author allen on 17-1-7.%0A */%0Aclass LongestPalindromicSubstring %7B%0A    fun longestPalindromicSubstring(s: String?): String %7B%0A        if (s == null %7C%7C s.length %3C= 1) %7B%0A            return s%0A        %7D%0A%0A        val chars = s.toCharArray()%0A        val sLen = s.length%0A        var maxLen = 0%0A        var maxStart = 0%0A        var index = 0%0A        var left: Int%0A        var right: Int%0A        var len: Int%0A        while (index %3C= sLen - maxLen / 2) %7B%0A            right = index%0A            left = right%0A            while (right %3C sLen - 1 && chars%5Bright + 1%5D == chars%5Bright%5D) %7B%0A                right++%0A            %7D%0A            index = right + 1%0A            while (left %3E 0 && right %3C sLen - 1 && chars%5Bleft - 1%5D == chars%5Bright + 1%5D) %7B%0A                left--%0A                right++%0A            %7D%0A            len = right - left + 1%0A            if (maxLen %3C len) %7B%0A                maxLen = len%0A                maxStart = left%0A            %7D%0A        %7D%0A        return s.substring(maxStart, maxStart + maxLen)%0A    %7D%0A%7D%0A

add longest palindromic substring