import java.util.HashMap;
import java.util.Map;
import java.lang.Character;

public class CountingDuplicates {
  public static int duplicateCount(String text) {
    HashMap<Character, Integer> duplicates = new HashMap<Character, Integer>();
    for (int i = 0; i< text.length(); i++){
      Character symbol = Character.toLowerCase(text.charAt(i));
      Integer count = duplicates.get(symbol);
      if(count == null){
        count = 0;
      } else {
        count = 1;
      }
      duplicates.put(symbol, count);
    }
    System.out.println(duplicates);
    int ans = 0;
    for(Map.Entry<Character, Integer> entry : duplicates.entrySet()){
      ans += entry.getValue();
    }
    return ans;
  }
}

public class CountingDuplicates {
    public static int duplicateCount(String text) {
      HashMap<Character, Integer> map = new HashMap<>();
        for (char c : text.toLowerCase().toCharArray()) {
            map.put(c, map.containsKey(c) ? 1 : 0);
        }
      return (int) map.values().stream().filter(e -> e > 0).count();
    }
}

import java.util.Map;
import static java.util.function.Function.identity;
import static java.util.stream.Collectors.counting;
import static java.util.stream.Collectors.groupingBy;

class CountingDuplicates {
    private static Map<Character, Long> charFrequenciesMap(final String text) {
        return text.codePoints()
            .map(Character::toLowerCase)
            .mapToObj(c -> (char) c)
            .collect(groupingBy(identity(), counting()));
    }
    
    static int duplicateCount(final String text) {
        return (int) charFrequenciesMap(text).values().stream()
            .filter(i -> i > 1)
            .count();
    }
}


@@ -521,44 +521,8 @@
   %7D%0A
-    System.out.println(duplicates);%0A
     
@@ -530,24 +530,24 @@
 nt ans = 0;%0A
+
     for(Map.
@@ -657,23 +657,1198 @@
 rn ans;%0A
-
   %7D%0A%7D%0A%0A
+import org.junit.Test;%0Aimport static org.junit.Assert.assertEquals;%0Aimport org.junit.runners.JUnit4;%0A%0Apublic class SolutionTest %7B%0A    @Test%0A    public void abcdeReturnsZero() %7B%0A        assertEquals(0, CountingDuplicates.duplicateCount(%22abcde%22));%0A    %7D%0A    %0A    @Test%0A    public void abcdeaReturnsOne() %7B%0A        assertEquals(1, CountingDuplicates.duplicateCount(%22abcdea%22));%0A    %7D%0A    %0A    @Test%0A    public void indivisibilityReturnsOne() %7B%0A        assertEquals(1, CountingDuplicates.duplicateCount(%22indivisibility%22));%0A    %7D%0A    %0A    @Test %0A    public void reallyLongStringContainingDuplicatesReturnsThree() %7B%0A        String testThousandA = new String(new char%5B1000%5D).replace('%5C0', 'a');%0A        String testHundredB = new String(new char%5B100%5D).replace('%5C0', 'b');%0A        String testTenC = new String(new char%5B10%5D).replace('%5C0', 'c');%0A        String test1CapitalA = new String(new char%5B1%5D).replace('%5C0', 'A'); %0A        String test1d = new String(new char%5B1%5D).replace('%5C0', 'd'); %0A        String test = test1d + test1CapitalA + testTenC + %0A            testHundredB + testThousandA;%0A        %0A%0A        assertEquals(3, CountingDuplicates.duplicateCount(test));%0A    %7D%0A    %0A    %0A%7D%0A%0A
 public c

Update Counting_Duplicates.java