Merge two strings on their longest overlap

0
Remix

Given two strings, join them so that the longest overlap between the end of one and the start of the other appears only once. Try both orders (first then second, and second then first), and keep the order with the longer overlap; on a tie, put the first string first. Return the merged string. Start with the direct approach, then make finding the overlap efficient (a prefix function or hashing).

AppleOnline assessmentLast asked Sep 2026
No answer yet. Write the first one; the best answer gets endorsed.