题解 | #查找兄弟单词#

查找兄弟单词

https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68

import sys

for line in sys.stdin:
    a = line.split(" ")
    num,k,word,restlt1 = int(a[0]),int(a[-1]),a[-2],[]
    a1 = a[1:-2]
    for e in range(num):
        if a1[e] != word and sorted(a1[e]) == sorted(word):
            restlt1.append(a1[e])
    restlt1.sort()
    if k < len(restlt1):
        print(len(restlt1))
        print(restlt1[k-1])
    else:
        print(len(restlt1))

全部评论

相关推荐

头像
08-05 15:59
已编辑
门头沟学院 运维工程师
点赞 评论 收藏
分享
苍蓝星上艾露:这简历。。。可以试试我写的开源简历优化工具https://github.com/weicanie/prisma-ai
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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