Given a list of words and an integer k, return the k most frequent words. Order the result by decreasing frequency, and for equal frequency use lexicographically smaller words first.
words = array of words, k = number of results
k most frequent words sorted by frequency desc and lexicographic asc on ties
Example 1:
Input:
words = ["i","love","leetcode","i","love","coding"] k = 2
Output:
["i","love"]
Explanation:
i and love are the two most frequent words.
Example 2:
Input:
words = ["the","day","is","sunny","the","the","the","sunny","is","is"] k = 4
Output:
["the","is","sunny","day"]
Explanation:
Frequencies are 4, 3, 2, and 1 respectively.