Top K Frequent Words
Try to solve the Top K Frequent Words problem.
We'll cover the following
Statement
Given a string array, words
, and an integer k
, return the most frequent strings.
Sort the frequencies from highest to lowest and then return the top frequent words. Words with the same frequency should be sorted by their lexicographical order.
Constraints:
-
words.length
-
words[i].length
-
words[i]
consists of lowercase English letters. -
is in the range
[1, The number of unique words[i]]
Examples
Level up your interview prep. Join Educative to access 70+ hands-on prep courses.