409. Longest Palindrome

題目

Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.

Letters are case sensitive, for example, "Aa" is not considered a palindrome here.

Example 1:

Input: s = "abccccdd"
Output: 7
Explanation: One longest palindrome that can be built is "dccaccd", whose length is 7.

Example 2:

Input: s = "a"
Output: 1
Explanation: The longest palindrome that can be built is "a", whose length is 1.

Constraints:

  • 1 <= s.length <= 2000
  • s consists of lowercase and/or uppercase English letters only.

題目大意

給定一個包含大寫字母和小寫字母的字符串,找到通過這些字母構造成的最長的回文串。 在構造過程中,請注意區分大小寫。比如 Aa 不能當做一個回文字符串。 注意:假設字符串的長度不會超過 1010。

解題思路

來源

解答

© Kimi Tsai all right reserved.            Updated : 2023-07-12 09:05:01

results matching ""

    No results matching ""

    results matching ""

      No results matching ""