Hacker News new | past | comments | ask | show | jobs | submit login

3-4 minutes!

Try this:

    for i in range(len(str)):
         for j in range(i, len(str)):
              if str[i:j] == str[i:j][::-1]:
                  #...
Choose the start and end indices. Then take a slice to see if it's a palindrome. Nice and speedy! :)



Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: