← Back to challenges

Longest Palindrome

PythonHardloopsstrings

Instructions

Given a string s, return the length of the longest palindrome that can be built with those letters.

Examples

longest_palindrome("a") ➞ 1

longest_palindrome("bb") ➞ 2

longest_palindrome("abccccdd") ➞ 7

longest_palindrome("") ➞ 0

Notes

N/A

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.