Below steps follow above recurrence
if not i : NEW_LINE INDENT dp [ i ] [ j ] = j ; NEW_LINE DEDENT elif not j : NEW_LINE INDENT dp [ i ] [ j ] = i ; NEW_LINE DEDENT elif ( a [ i - 1 ] == b [ j - 1 ] ) : NEW_LINE INDENT dp [ i ] [ j ] = 1 + dp [ i - 1 ] [ j - 1 ] ; NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = 1 + min ( dp [ i - 1 ] [ j ] , dp [ i ] [ j - 1 ] ) ; NEW_LINE DEDENT