implemented longest_intersec_substr algorithm