702. 连接两个字符串中的不同字符

702. 连接两个字符串中的不同字符

中文 English

给出两个字符串, 你需要修改第一个字符串,将所有与第二个字符串中相同的字符删除, 并且第二个字符串中不同的字符与第一个字符串的不同字符连接

样例

样例 1:

输入 : s1 = "aacdb", s2 = "gafd"
输出 : "cbgf"

样例 2:

输入 : "abcs", s2 = "cxzca"
输出 : "bsxz"
class Solution:
    """
    @param s1: the 1st string
    @param s2: the 2nd string
    @return: uncommon characters of given strings
    """
    def concatenetedString(self, s1, s2):
        # write your code here
        same_dic = []
        for i in s2:
            if i in s1:
                s1 = s1.replace(i,'')
                same_dic.append(i)
        
        for j in same_dic:
            s2 = s2.replace(j,'')
        
        return s1+s2
 

猜你喜欢

转载自www.cnblogs.com/yunxintryyoubest/p/12541475.html