In two strings:
\"Mary Had a Little Lamb\" \"Mary Had a Big Lamb\"
should return
\"Mary Had a \"
Use binary search. Try to compare whole strings. If they are not equal try to compare the first characters. If they are equal try to split the strings (substring(0, str.length()/2). Etc, etc.
substring(0, str.length()/2