text of lowercase English letters. Choose two subsequences of it so that each reads the same forwards and backwards and no position of the string is used by both.
Return the largest possible product of their lengths.
A subsequence is what remains after deleting some characters (possibly none) without changing the order of the rest.text="racecars" → 12
Take "raar" (positions 0, 1, 5, 6) and "cec" (positions 2, 3, 4): no shared positions, both are palindromes, 4 · 3 = 12. Taking all of "racecar" leaves only "s" for the other, giving just 7 · 1 = 7.
text="xy" → 1
Every single letter is a palindrome: "x" and "y", 1 · 1 = 1.
text consists of lowercase English letterstext="racecars"
12
Run checks the first 3 tests in your browser. Submit checks all 63 tests on the server, hidden ones included.