Back to DSA sheet

Maximum Product of The Length of Two Palindromic Subsequences

MediumArrays

Choose two subsequences that use disjoint index sets, where each chosen subsequence is a palindrome. Maximise the product of their lengths.

Input format (stdin): a single line, the string (length up to 12). Output the maximum product.

Examples
Input: leetcodecom
Output: 9
e.g. 'eee' and 'cdc' give 3*3=9.
Input: bb
Output: 1
'b' and 'b' give 1*1=1.
Constraints
  • 2 <= length <= 12
  • lowercase English letters
Sheets
NeetCode 250
maximum-product-of-the-length-of-two-palindromic-subsequences.cpp3 sample tests
Loading editor
Test results

Run the sample tests to check your solution against expected output.

Custom input (stdin)
Output

Run your code to see its output.