e.g "ccddcc" in the string "abaccddccefe"
I thought of a solution but it runs in O(n^2) time
Algo 1:
Steps: Its a brute force method
Issues: 1. This algo runs in O(n^2) time.
Algo 2:
Can you guys think of an algo which runs in a better time. If possible O(n) time
You can find the the longest palindrome using Manacher's Algorithm in O(n)
time! Its implementation can be found here and here.
For input String s = "HYTBCABADEFGHABCDEDCBAGHTFYW1234567887654321ZWETYGDE"
it finds the correct output which is 1234567887654321
.