Count unique numbers that can be generated from N by adding one and removing trailing zeros | Function to count the unique numbers ; If the number has already been visited ; Insert the number to the set ; First step ; Second step remove trailing zeros ; Recur again for the new number ; Driver code
def count_unique ( s , n ) : NEW_LINE INDENT if ( s . count ( n ) ) : NEW_LINE INDENT return ; NEW_LINE DEDENT s . append ( n ) ; NEW_LINE n += 1 ; NEW_LINE while ( n % 10 == 0 ) : NEW_LINE INDENT n = n // 10 ; NEW_LINE DEDENT count_unique ( s , n ) ; NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT n = 10 NEW_LINE s = [ ] NEW_LINE count_unique ( s , n ) NEW_LINE print ( len ( s ) ) NEW_LINE DEDENT