First crack at LCS problem (too slow).