Back to course home
0% completed
Vote For New Content
Problem 4: Longest Palindrome(easy)
Problem Statement:
Given a string, determine the length of the longest palindrome that can be constructed using the characters from the string. You don't need to return the palindrome itself, just its maximum possible length.
Examples:
-
- Input: "applepie"
- Expected Output: 5
- Justification: The longest palindrome that can be constructed from the string is "pepep", which has a length of 5. There are are other palindromes too but they all will be of length 5.
-
- Input: "aabbcc"
- Expected Output: 6
- Justification: We can form the palindrome "abccba" using the characters from the string, which has a length of 6.
-
- Input: "bananas"
- Expected Output: 5
- Justification: The longest palindrome that can be constructed from the string is "anana", which has a length of 5.
Constraints:
1 <= s.length <= 2000
s
consists of lowercase and/or uppercase English letters only.
Try it yourself
Try solving this question here:
Python3
Python3
. . . .
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible