Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Solution: 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. Return the maximum possible length of the palindromic string.


    • 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




Like the course? Get enrolled and start learning!