#3503

Longest Palindrome After Substring Concatenation I

medium · 43.8% accepted · 82 likes · top 25%

two pointers · string · dynamic programming · enumeration

Description

You are given two strings, s and t.

You can create a new string by selecting a substring from s (possibly empty) and a substring from t (possibly empty), then concatenating them in order.

Return the length of the longest palindrome that can be formed this way.

Solution