Deviopath › JavaScript

Top K Frequent Words

Medium · Strings

Write a function topKFrequent that returns the k most frequent words from the array words.

Sort by count (highest first). Words with the same count are sorted alphabetically. If there are fewer than k different words, return all of them. All words are lowercase.

Next: Rotate a Matrix