题解 | #字符串字符匹配#

字符串字符匹配

https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

while True:
    try:
        l = []
        s = input()
        T = input()
        for i in s:              #遍历s中字符
            for x in T:          #遍历T中字符
                if x == i:       #如果s中的字符在T中也有则添加到l
                    l.append(i)
        s1 = set(''.join(l))              #删除重复元素并变为set
        s2 = set(s)              #将s也变为set
        if s2 == s1:             #如果两set相等则为true
            print('true')
        else:
            print('false')
    except:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务