题解 | 查找兄弟单词

查找兄弟单词

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

import sys
lst_0 = input().split()
k=int(lst_0[-1])-1
x=lst_0[-2]
x_1=set(x)
lst_2 = lst_0[1:-2]
dc={}
lst_f=[]
for i in x_1:
    dc[i]=x.count(i)
for word in lst_2:
    ddc={}
    if word!=x:
        for i in set(word):
            ddc[i]=word.count(i)
        if dc==ddc:
            lst_f.append(word)
print(len(lst_f),end="\n")
if k+1 <= len(lst_f):
    print(sorted(lst_f)[k])

全部评论

相关推荐

02-11 14:29
已编辑
字节跳动_QA
Edgestr:这种的写代码最狠了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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