char not present in T
if k == - 1 : NEW_LINE INDENT dp [ i ] [ j ] = 1 NEW_LINE DEDENT else : NEW_LINE INDENT dp [ i ] [ j ] = min ( dp [ i - 1 ] [ j ] , dp [ i - 1 ] [ k ] + 1 ) NEW_LINE DEDENT ans = dp [ m ] [ n ] NEW_LINE if ans >= MAX : NEW_LINE ans = - 1 NEW_LINE return ans NEW_LINE