A palindrome is a string which reads the same backward as it does forward.
The candidate should create a solution that, when given a string input, returns the longest palindrome substring within the provided string.
For example, in the string "I drive a red racecar",
"racecar" would be the longest palindrome findable.
If a palindrome of at least two characters cannot be found, return NULL
.
- Demonstrate their solution through unit tests
- Openly discuss their approach and ask appropriate questions
The candidate can demonstrate the following input/outputs through the use of unit tests
Input (palindromes underlined) | Expected Output |
---|---|
No Palindrome | NULL |
php | php |
banana | anana |
papaya | pap* |
Lets visit the zoo | isi |
*if multiple of the same length, return the first found.
php composer.phar install
./vendor/bin/phpunit tests/LongestPalindromeFinderTest.php