lcs algorithm with iterations, too slow
with shortcut
roughly implemented