Solving this problem based on string and dp

Help me in solving THIS PROBLEM

You can use map in c++, dictionary in python or hashing in general.Find hashing of all the elements which need to be found k time and then start reading the paragraph. Step by step check if the mapping of the word in paragraph needed if yes increment the counter of that map by 1.

When every counter is >=k then stop and print all the words till now.