'Palindromic sub-sequences but analyze a sentence instead of a word in PHP

Given a word composed of lowercase English letters, find the maximum possible score by building exactly 2 palindromic sub-sequences. The score obtained is the product of the length of these 2 sub-sequences. What tests would you write to verify your program?

for e.g. If the word is

abcdefAnnaRacecarMom

the palindromes are Anna (4), Racecar (7), and Mom (3). The maximum product is

is Anna - 4 , RaceCar - 7 = 4*7 = 28

How would the program need to change if it needs to analyze a sentence instead of a word and produce a similar result? e.g 'King, are you glad you are king'?

php


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source