We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I feel this is a very complicated answer. You can solve this problem in 10 lines, using the same logic as you would manually do when you solve it by hand :
For each index i in the string, I create a cursor k that starts from i and goes forward until it meets a different letter than s[i] at s[i+k]. Then I check if the string starting from s[i] centrered on s[i+k] could be a palindrome.
I put my code in this discussion
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Special String Again
You are viewing a single comment's thread. Return to all comments →
I feel this is a very complicated answer. You can solve this problem in 10 lines, using the same logic as you would manually do when you solve it by hand : For each index i in the string, I create a cursor k that starts from i and goes forward until it meets a different letter than s[i] at s[i+k]. Then I check if the string starting from s[i] centrered on s[i+k] could be a palindrome.
I put my code in this discussion