I found similar questions on StackOverflow, but my question is different.
Given a string s contains lowercase alphabet. I want to find the
s
alphabet
As mentioned by Aditya, this can be solved using Z-Algorithm. Please find the detailed explanation with implementation here - https://www.hackerearth.com/practice/algorithms/string-algorithm/z-algorithm/tutorial/