Build the longest palindrome length possible from the letters of a given string.
Given a string s consisting of lowercase and/or uppercase English letters, determine the maximum length of a palindrome that can be built using the characters of s.
You may rearrange the characters in any order, but each character can be used at most as many times as it appears in the input.
A palindrome reads the same forward and backward.
Return the length of the longest palindrome that can be formed.
s.s.1 <= s.length.s.Example 1
Input
s = "abccccdd"
Output
7
Explanation
One longest palindrome is "dccaccd". It uses 2 d's, 4 c's, and 1 a or b as the center, giving length 7.
Example 2
Input
s = "a"
Output
1
Explanation
A single character is already a palindrome.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.