Dynamic Programming approach for LCS