Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindrome by Concatenating Two-Letter Words

Longest Palindrome by Concatenating Two-Letter Words asks you to choose some two-letter strings from an array and return the length of the longest palindrome they can form, using each word at most once.

Statement

Suppose you are given an array of strings, words, and each element in the array has a length of two. You need to return the length of the longest palindrome that can be made by concatenating some elements from words. If no palindrome can be made, return 0.

A palindrome is a sequence of characters that reads the same forward and backward.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000
  • words[i].length =2= 2
  • Each word can be used at most once.
  • words should only consist of lowercase English letters.
⋮
Tap here to switch tabs
Problem
Submissions

Problem: Longest Palindrome by Concatenating Two-Letter Words

Longest Palindrome by Concatenating Two-Letter Words asks you to choose some two-letter strings from an array and return the length of the longest palindrome they can form, using each word at most once.

Statement

Suppose you are given an array of strings, words, and each element in the array has a length of two. You need to return the length of the longest palindrome that can be made by concatenating some elements from words. If no palindrome can be made, return 0.

A palindrome is a sequence of characters that reads the same forward and backward.

Constraints:

  • 1≤1 \leq words.length ≤1000\leq 1000
  • words[i].length =2= 2
  • Each word can be used at most once.
  • words should only consist of lowercase English letters.