C++ map handles this problem perfectly. Keep a map of type<string,int> and increase the corresponding string element in this map by 1 after reading each name. Then loop over all the elements of the map and check if the current one has a value greater than 2 output that word and continue.
No comments:
Post a Comment