Leetcode Longest Common Sequence Algorithm