MCPcopy Index your code
hub / github.com/Tiwarishashwat/InterviewCodes / countDuplicates

Method countDuplicates

DuplicateCount.java:8–19  ·  view source on GitHub ↗
(String inp)

Source from the content-addressed store, hash-verified

6 countDuplicates(s);
7 }
8 public static void countDuplicates(String inp)
9 {
10 HashMap<Character,Integer> map = new HashMap<>();
11 for(int i=0;i<inp.length();i++)
12 {
13 map.put(inp.charAt(i),map.getOrDefault(inp.charAt(i),0)+1);
14 }
15 for(Map.Entry<Character,Integer> e : map.entrySet())
16 {
17 System.out.println(e.getKey() + ":" + e.getValue());
18 }
19 }
20}

Callers 1

mainMethod · 0.95

Calls 1

getValueMethod · 0.80

Tested by

no test coverage detected