2131. Longest Palindrome by Concatenating Two Letter Words
Medium
You are given an array of strings words
. Each element of words
consists of two lowercase English letters.
Create the longest possible palindrome by selecting some elements from words
and concatenating them in any order. Each element can be selected at most once.
Return the length of the longest palindrome that you can create. If it is impossible to create any palindrome, return 0
.
A palindrome is a string that reads the same forward and backward.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= words.length <= 105
words[i].length == 2
words[i]
consists of lowercase English letters.
解題
Runtime: 251 ms, faster than 91.47%
Memory Usage: 12.6 MB, less than 97.67%
Previous2130. Maximum Twin Sum of a Linked ListNext2133. Check if Every Row and Column Contains All Numbers
Last updated