Skip to content

Top K Frequent Words #277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
matthewsamuel95 opened this issue Oct 3, 2018 · 4 comments
Closed

Top K Frequent Words #277

matthewsamuel95 opened this issue Oct 3, 2018 · 4 comments

Comments

@matthewsamuel95
Copy link
Owner

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.

Example 1: 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.

Example 2: Input: ["the", "day", "is", "sunny", "the", "the", "the", "sunny", "is", "is"], k = 4 Output: ["the", "is", "sunny", "day"] Explanation: "the", "is", "sunny" and "day" are the four most frequent words, with the number of occurrence being 4, 3, 2 and 1 respectively.

@JerBast
Copy link
Contributor

JerBast commented Oct 3, 2018

What category do you want this to be in?

@JerBast
Copy link
Contributor

JerBast commented Oct 3, 2018

Added Python version for the 'top K frequent words' (#288)

@SLR1999
Copy link
Contributor

SLR1999 commented Oct 3, 2018

Can I implement a code in java for the above purpose?

@matthewsamuel95
Copy link
Owner Author

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants