Update dp [ ] [ ] on the basis recurrence relation
if ( j == 0 ) : NEW_LINE INDENT dp [ i ] [ j ] = ( str [ j ] == currentChar ) NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = dp [ i ] [ j - 1 ] + NEW_LINE INDENT ( str [ j ] == currentChar ) NEW_LINE DEDENT DEDENT