Description

Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

Examples

Input:s = "abccccdd"
Output:7
Explanation:

dccaccd uses 7 chars.

Input:s = "aabbcc"
Output:6
Explanation:

All characters appear in pairs, so all 6 characters can form a palindrome like "abccba".

Input:s = "racecar"
Output:7
Explanation:

Character pairs: r(2), a(2), c(2), and one single e. All pairs plus one odd character in the center form a palindrome: "racecar" uses all 7 characters.

Constraints

  • 1 ≤ s.length ≤ 2000

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!