id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

peter@norvig.com wordgames > longest_subpalindrome
prev  |  next  |  chance

Given a string, what substring of it forms the longest palindrome? For this problem, unlike the previous palindrome problem, we're looking for an exact match palindrome: spaces and punctuation counts, and an upper-case letter is different from a lower-case. Write longest_subpalindrome(string) to return the longest palindrome substring. See if you can make it relatively efficient.


longest_subpalindrome('hello, world') → 'll'
longest_subpalindrome('radar racecar') → 'racecar'
longest_subpalindrome('when in the course of human events it becomes necessary') → 'eve'

...Save, Compile, Run (ctrl-enter)

def longest_subpalindrome(string):

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Python Help

Difficulty: 231 Post-solution available

Copyright Nick Parlante 2017 - privacy