Wednesday, 16 November 2016

Text File words count

Suppose you have a text file, I want total number of words and which word how many times came. How will you approach it?

Solution-
1. First I will read file as string.
2. I will split the string based on space and store in Array.
3. Take A dictionary and key will be word and value will be count for that word.
4. If same word or key repeats then increment the count by one.
5. Enjoy...





No comments:

Post a Comment