Top-k-frequency Words

easy
1.Given a non empty words. 2.You have to print the k most frequency elements. 3.You have to complete the function print() which should return the list of strings.

Input Format

1.First line contains an integer 'N' deonting the number of words. 2.Second line contains 'N' separated words. 3.Third line contains an intger 'K'.

Output Format

1.Return the ArrayList of strings from the function. 2.ArrayList will be displayed as output.

Constraints

1 <= k <= number of unique elements.

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
10
the day is sunny the the the sunny is is
4
Output
[day, is, sunny, the]
Previous
Top K Frequent Elements
Next
Two Sum

Related Questions