题解 | #查找兄弟单词#

查找兄弟单词

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

def solution(x,k,strs):
    c = sorted(x)
    tmp = []
    for s in strs:
        if sorted(s) == c and s!=x:
            tmp.append(s)
    tmp = sorted(tmp)
    m = len(tmp)
    print(m)
    if k <= m:
        print(tmp[k-1])

while True:
    try:
        strs = input().split()
        x,k = strs[-2], int(strs[-1])
        solution(x,k,strs[1:-2])
    except:
        break

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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