NewProject Coding is here — build features and fix bugs in real codebases with an AI assistantSee what's new

Given two strings str1 and str2, implement a function that concatenates them by merging the longest common substring that appears as a suffix of str1 and a prefix of str2.

Constraints:

  • 1 ≤ str1.length, str2.length ≤ 10510^5
  • str1 and str2 only consist of lowercase English letters.
Test Cases
Input
Output
Expected