LeetCode Longest Palindrome
本文最后更新于 2026年7月17日 下午
Description
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.
This is case sensitive, for example “Aa” is not considered a palindrome here.
Note:
Assume the length of given string will not exceed 1,010.
Example:
1 | Input: |
The original problem is here.
My Solution
I solve this problem in C++, as below:
1 | class Solution { |
Note
To solve the problem, use a vector with length 52 for all letters to save the frequence.
LeetCode Longest Palindrome
http://zhaoshuaijiang.com/2017/01/19/leetcode/leetcode-longest-palindrome/