Implement Longest Common Subsequence algorithm with dynamic programming.