If the current digit is 1 , any digit from [ 1 - 9 ] can be placed . If N == 1 , 0 can also be placed .
if ( digit == 1 ) : NEW_LINE INDENT term = 0 if N == 1 else 1 NEW_LINE for j in range ( term , 10 , 1 ) : NEW_LINE INDENT dp [ digit ] [ prev1 ] [ prev2 ] += countOfNumbers ( digit + 1 , j , prev1 , N ) NEW_LINE DEDENT DEDENT