How to find the Longest Prefix and Suffix of a given string?
Well you are looking for KMP algorithm.I would suggest you to go through following links and if you face any problem feel free to ask
Hope it helps
CAn you please elaborate? Is the question like you are given a string S and then a set of prefix and suffixed strings and have to find the longest prefix and suffix in them?
Or does the Q involve finding longest common prefix, as @invoation answered?
Well, in case it is like finding common prefix then innovation already answered.
But in case you need more help, I think this article would help you
String Matching: Longest Suffix Prefix Array in KMP logic