#K53547. Longest Palindrome Reorder
Longest Palindrome Reorder
Longest Palindrome Reorder
Given a string s
, determine the length of the longest substring that can be rearranged to form a palindrome. A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward.
The idea is to count the frequency of each character and use as many pairs of characters as possible, and if any character has an odd count, one additional character can be placed in the middle of the palindrome.
Note: The input string may contain any printable characters. In the case of an empty string, the result should be 0.
inputFormat
The input consists of a single line containing the string s
.
outputFormat
Output a single integer representing the length of the longest palindrome that can be built using the characters from s
.
abccccdd
7
</p>