题解 | #查找兄弟单词#

查找兄弟单词

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

while True:
    try:
        inn = input().split(' ')
        s = sorted(inn[1:int(inn[0])+1])
        target = inn[int(inn[0])+1]
        th = int(inn[-1])
        dict1 = {}
        res = 0
        list2 = []
        for word in s:
            string = ''.join(sorted(word))
            if word not in dict1:
                dict1[word] = [string,1]
            else:
                dict1[word][1] += 1
        for key,value in dict1.items():
            if key != target and value[0] ==  ''.join(sorted(target)):
                res += value[1]
                for _ in range(value[1]):
                    list2.append(key)
        print(res)
        print(list2[th-1])
    except:
        break
全部评论

相关推荐

被子有点短:有了实习后会发现有实习也没用
投递字节跳动等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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