You are given a list of city names & you need to find the number of times each name is appearing in the given list.
e.g. : List<String> cities = List.of("a","b","c","b","d","a");
o/p should be like : {a=2, b=2, c=1, d=1}
e.g. : List<String> cities = List.of("a","b","c","b","d","a");
o/p should be like : {a=2, b=2, c=1, d=1}
I think we can also use reduce(), but haven't tried that yet. And will be again giving some
complex solution.
complex solution.