Length Of Longest Palindrome

Start Timer

0:00:00

Given a string, find the length of the largest palindrome that can be made from the characters in the string. We may use each character at most once and rearrange them freely. Every character counts as written: spaces and punctuation are characters, and uppercase and lowercase letters are different ('Aa' gives 1).

Example 1:

Input:

s = 'racecar'

Output:

longest_palindrome(s) -> 7

In this example, the entire string ‘racecar’ is a palindrome.

Example 2:

Input:

s = 'aabbcc'

Output:

longest_palindrome(s) -> 6
.
.
.
.
.


Comments

Loading comments