Longest Common String Algorithm