Saturday, November 4, 2017

[LeetCode]Top K Frequent Words


题目要求log(n * k)的解法,我们先扫一遍array用map记录每一个单词的出现数量,之后用priority queue统计top k即可,保证priority queue的size小于等于k。代码如下:


No comments:

Post a Comment