SP21096 WORDCNT2 - Word Counting 2

Description

“I have hated words and I have loved them, and I hope I have made them right.” ― Markus Zusak We also love words, don’t we? However, we are code poets, so, we love words in a different way. How about counting them? Yes, counting word seems to be a good thing and has a huge application in computer science. Well, counting may sometimes sound boring, but many hidden knowledge can be achieved from counting. For example, finding the most frequent word in vast collection of documents, which then in turns, can be used to classify those documents. But fear not! We are not interested in large documents right now. In fact, in our extremely busy world, offline data processing algorithms are getting obsolete day by day. Instead of words in large files, we are now more interested in streams of words. The idea is quite simple, your program will keep reading from a stream where new words are continuously being fed to your program, but due to limited storage, your program can only remember the latest K words. So, when (K+1) $ ^{th} $ word arrives, your program forgets the 1 $ ^{st} $ word, when (k+2) $ ^{th} $ word arrives, your program forgets the 2 $ ^{nd} $ word, and so on. We want you to find the most frequent word over the latest K words each time a new word arrives.

Input Format

N/A

Output Format

N/A