Skip to content

Latest commit

 

History

History
20 lines (13 loc) · 595 Bytes

README.md

File metadata and controls

20 lines (13 loc) · 595 Bytes

45.Top K Frequent Words

Description

Given a non-empty list of words, return the k most frequent elements.

Your answer should be sorted by frequency from highest to lowest. If two words have the same frequency, then the word with the lower alphabetical order comes first.

Examples

Input: ["i", "love", "leetcode", "i", "love", "coding"], k = 2
Output: ["i", "love"]
Explanation: "i" and "love" are the two most frequent words.
    Note that "i" comes before "love" due to a lower alphabetical order.

From

LeetCode