标签:
https://leetcode.com/problems/longest-palindrome/ public class Solution { public int longestPalindrome(String s) { char []charr = s.toCharArray(); Arrays.sort(charr); int result = 0; for (int i=0; i<charr.length; i++) { if (i==charr.length-1) { break; } if (charr[i] == charr[i+1]) { result += 2; i++; } } if (result < charr.length) { result++; } return result; } }
标签:
原文地址:http://www.cnblogs.com/charlesblc/p/5929656.html