Interview Question
Software Engineer / DevelopersCountry: United States
use suffix tree... create suffix tree of both strings... and at end of each branch out the string name... if any branch has both strings name, then you last complete word before the leaf node is the longest suffix.... then you can append string2 to string 1, where string 2 is starting from 0 + len of longest suffix
Is it given that which of the two strings can be the first string? Or is it that programmer has to write program so that it takes care of both cases: one string being the first or the other string being the first?
- Learner June 12, 2012