Lexicographically smallest numeric string having odd digit counts | Function to construct lexicographically smallest numeric string having an odd count of each characters ; Stores the resultant string ; If N is even ; Otherwise ; Driver code
def genString ( N ) : NEW_LINE INDENT ans = " " NEW_LINE if ( N % 2 == 0 ) : NEW_LINE INDENT ans = " " . join ( "1" for i in range ( N - 1 ) ) NEW_LINE ans = ans + "2" NEW_LINE DEDENT else : NEW_LINE INDENT ans = " " . join ( "1" for i in range ( N ) ) NEW_LINE DEDENT return ans NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT N = 5 NEW_LINE print ( genString ( N ) ) NEW_LINE DEDENT