Practice Maximize Palindrome Length From Subsequences
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Choose a nonempty subsequence of word1 and a nonempty subsequence of word2, preserving the order of letters within each. Concatenate the first subsequence followed by the second. Return the greatest length obtainable when the concatenation is a palindrome, or 0 if no such palindrome exists.
Source: Maximize Palindrome Length From Subsequences on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
word1 = "cacb", word2 = "cbba"
5
# Example 2
word1 = "ab", word2 = "ab"
3
# Example 3
word1 = "aa", word2 = "bb"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Maximize Palindrome Length From Subsequences.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.