Created
October 15, 2017 16:12
-
-
Save joshuashaffer/3db7ad71bb6338f313b4f41ac2658168 to your computer and use it in GitHub Desktop.
Given two strings s1 and s2, merge them into one string by overlapping the suffix of the first string and the prefix of the second string. If there's nothing to concatenate, return the concatenation of the strings.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #define x substr | |
| auto singkatan(auto w, auto q) { | |
| int a=w.length(),b=q.length(),m=a<b?a:b; | |
| while(m--)if(w.x(a-m-1,m+1)==q.x(0,m+1))q=q.x(m+1,b-m); | |
| return w+q; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment