An analytics widget shows the most-used emoji reactions in a chat. Write topKFrequent(items, k), which returns the k values that occur most often in items.
topKFrequent(['👍', '🎉', '👍', '❤️', '🎉', '👍', '😂'], 2);
// ['👍', '🎉'] (👍 ×3, 🎉 ×2)
topKFrequent([4, 4, 1, 1, 1, 9], 1); // [1]
topKFrequent([7], 1); // [7]
===. A number 1 and a string '1' are different values.k values in any order.1 ≤ k ≤ the number of distinct values.Spotted a mistake or a rights concern? Report an issue