Print all distinct strings from a given array | Function to find the distinct strings from the given array ; Stores distinct strings from the given array ; Traverse the array ; If current string not present into the set ; Insert current string into the set ; Traverse the set DistString ; Print distinct string ; Driver Code ; Stores length of the array
def findDisStr ( arr , N ) : NEW_LINE INDENT DistString = set ( ) NEW_LINE for i in range ( N ) : NEW_LINE INDENT if ( arr [ i ] not in DistString ) : NEW_LINE INDENT DistString . add ( arr [ i ] ) NEW_LINE DEDENT DEDENT for string in DistString : NEW_LINE INDENT print ( string , end = " ▁ " ) NEW_LINE DEDENT DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT arr = [ " Geeks " , " For " , " Geeks " , " Code " , " Coder " ] NEW_LINE N = len ( arr ) NEW_LINE findDisStr ( arr , N ) NEW_LINE DEDENT