Concatenate two strings, writing their longest shared end and start only once.
Unlock detailed company stats for this questionUpgrade
Factorize the extremities of two ASCII strings str1 and str2. Return a single string initially made from the concatenation of the two given strings, where the longest substring common to the end of the first string and the beginning of the second one is factorized (written only once). Decide the concatenation order (str1 + str2 or str2 + str1) so that you get the best factorization. When both orders factorize the same number of characters, prioritize str1 + str2.
Example: str1 = "1234yyabc", str2 = "abcxxxx1234" returns "abcxxxx1234yyabc" (factorizing "abc" via the str2 + str1 order).
Community answers
No answers contributed by the community yet.
Related questions
Find the longest common subsequence of two strings.Related courses

Course

Course
Course
