lcs: Reduce space complexity to O(n) for input lengths m, n

More accurately the new algorithm uses 2n memory. The previous
algorithm's space complexity was O(m*n) for input lengths m, n. Doesn't
have a noticeable impact on runtime, but it was an interesting
experiment.