Capco interview question

Implement method to count repeated words in String