Add LCS algorithm for Java