题解 | 查找兄弟单词

def is_brother(s, target):
    if len(s) != len(target) or s == target:
        return False
    return sorted(s) == sorted(target)

n, *words, x, k = input().split()
n = int(n)
k = int(k)

brother_words = []
for s in words:
    if is_brother(s, x):
        brother_words.append(s)
print(len(brother_words))
if k <= len(brother_words): #特别地,如果不存在,则不输出任何内容
    print(sorted(brother_words)[k-1])

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-08 13:15
点赞 评论 收藏
分享
06-07 19:59
门头沟学院 C++
补药卡我啊😭:都快15年前的了还在11新特性
你的简历改到第几版了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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