hachyderm.io is one of the many independent Mastodon servers you can use to participate in the fediverse.
Hachyderm is a safe space, LGBTQIA+ and BLM, primarily comprised of tech industry professionals world wide. Note that many non-user account types have restrictions - please see our About page.

Administered by:

Server stats:

8.9K
active users

Šimon Tóth

Common C++ interview problem: Top k frequent values.

Given a list of integers as std::vector<int> and the count k, return the top k most frequent values in the list in any order.

You can assume that the input leads to a unique solution, and your solution is required to operate faster than O(n*logn).

Solve it yourself: compiler-explorer.com/z/7E5bjq
Solution: compiler-explorer.com/z/eKqcYP