题解 | 查找兄弟单词
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
line = list(input().split())
n = int(line[0])
s = []
for i in range(1,n+1):
s.append(line[i])
x = line[n+1]
k = int(line[-1])
res = []
# 排序后比较(判断字母异位词)
x_sorted = ''.join(sorted(x))
res = []
for word in s:
if ''.join(sorted(word)) == x_sorted and word!=x:
res.append(word)
# 输出数量
print(len(res))
# 排序结果
res.sort()
if len(res)>=k:
print(res[k-1])