牛牛是一个狂热的音乐爱好者,他收集了一系列的歌曲名字。现在牛牛想知道他收藏的歌曲中,出现频率最低的前K个歌曲。 请你编写一个函数,接收一个字符串数组words和一个整数k作为参数,返回出现频率最低的前K个歌曲。如果有多个歌曲的频率相同,按照字典序从小到大排序。
示例1

输入

["song1","song2","song3","song1","song2","song4"],2

输出

["song3","song4"]
示例2

输入

["today","is","a","good","day","today","is","is"],3

输出

["a","day","good"]

备注:
1 1 words[i]由小写英文字母组成k的取值范围为[1, words中不同歌曲的数量]
加载中...