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

字符串字符匹配

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

import sys

while True:
    try:
        s1 = input().strip()
        s2 = input().strip()

        s1 = list(set(s1))
        s2 = list(set(s2))

        ans = 0
        for i in s1:
            if i in s2:
                ans += 1
        if ans == len(s1):
            print('true')
        else:
            print('false')





    except:
        break

全部评论
字符串可以直接转换为集合,集合再转换成列表,再判断是否存在每个元素,和长度对比即可得出是否全部存在于长字符串中
点赞 回复 分享
发布于 2024-05-17 09:57 广东

相关推荐

深夜书店vv:腾讯是这样的,去年很多走廊都加桌子当工区
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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