Compute the K Most Frequent Queries
EPI 13.5
Description:
You are given an array of strings. Computer the k strings that appear most frequently in the array.
Example:
Note
Idea:
简单。
- use hashmap to count the frequency of the strings.
- either use min heap of size k.
- or use quick select to find the k most frequent strings.
Code:
Code