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:

简单。

  1. use hashmap to count the frequency of the strings.
  2. either use min heap of size k.
  3. or use quick select to find the k most frequent strings.

Code:

Code

results matching ""

    No results matching ""