Loading problem...
You are given a string s containing a mix of lowercase and uppercase English letters. Your task is to determine the maximum possible length of a palindrome that can be constructed by rearranging the characters of the string.
A palindrome is a sequence of characters that reads identically forwards and backwards (e.g., "radar", "level", "AbcbA").
When constructing the palindrome, you may use each character from the input string at most once. You do not need to use all characters—only select those that help maximize the palindrome's length.
Important: Letters are case-sensitive, meaning 'A' and 'a' are treated as distinct characters and cannot be paired together.
Return the length of the longest palindrome that can be built using the letters from the input string.
s = "abccccdd"7One possible palindrome of maximum length is "dccaccd". There are four 'c' characters (all can be used symmetrically), two 'd' characters (used on both ends), and one character ('a') can be placed in the center. Total length = 4 + 2 + 1 = 7.
s = "a"1The only character available is "a", which forms a single-character palindrome of length 1.
s = "Aa"1Since "A" (uppercase) and "a" (lowercase) are treated as different characters, they cannot form a pair. Only one of them can be used as the center of the palindrome, resulting in a maximum length of 1.
Constraints