题解 | #查找兄弟单词#
查找兄弟单词
http://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
s = [i for i in input().strip().split(" ")]
# 字典中的单词列表,目标单词,第p个兄弟单词,兄弟单词列表
words, x, p, brothers = s[1:-2], s[-2], int(s[-1]), []
x_sort = sorted(x)
for word in sorted(words): # 这个地方需要特别注意【按字典序排列后的第 k 个单词】,不然最后输出的第p个单词位置不对
if word != x and sorted(word) == x_sort:
brothers.append(word)
print(len(brothers))
if brothers and p <= len(brothers):
print(brothers[p-1])