Concatenated string with uncommon characters of two strings | Python3 program Find concatenated string with uncommon characters of given strings ; res = " " result ; store all characters of s2 in map ; Find characters of s1 that are not present in s2 and append to result ; Find characters of s2 that are not present in s1 . ; Driver Code
def concatenetedString ( s1 , s2 ) : NEW_LINE INDENT m = { } NEW_LINE for i in range ( 0 , len ( s2 ) ) : NEW_LINE INDENT m [ s2 [ i ] ] = 1 NEW_LINE DEDENT for i in range ( 0 , len ( s1 ) ) : NEW_LINE INDENT if ( not s1 [ i ] in m ) : NEW_LINE INDENT res = res + s1 [ i ] NEW_LINE DEDENT else : NEW_LINE INDENT m [ s1 [ i ] ] = 2 NEW_LINE DEDENT DEDENT for i in range ( 0 , len ( s2 ) ) : NEW_LINE INDENT if ( m [ s2 [ i ] ] == 1 ) : NEW_LINE INDENT res = res + s2 [ i ] NEW_LINE DEDENT DEDENT return res NEW_LINE DEDENT if __name__ == " _ _ main _ _ " : NEW_LINE INDENT s1 = " abcs " NEW_LINE s2 = " cxzca " NEW_LINE print ( concatenetedString ( s1 , s2 ) ) NEW_LINE DEDENT