Published: Nov 11 2012 / 09:37
As interviewer, my next question would be "great, now assume Collections.frequency didn't exist. How would you do it then?" And strictly speaking, your answer still needs to eliminate words that have frequency 1.
You can ask. You are the boss... Let me make a wild guess. In my other simplest solution, I will sort the collection so that it makes similar words in sequence. Now a simple iteration will filter out all different words and their frequency.. including one also. You can choose them to ignore. I know this solution can have some performance overhead, but for that large load of data, I will go for some expert algorithm implementation. Otherwise, it is also good to go.
Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.