I have to write a program that counts the uniques characters in a String given by the user. For example \"abc\" returns 3 and \"aabbccd\" returns 4. I am not allow to use advan
public static long calculateDistinctSubStringSum(String text) {
Map map = new HashMap();
char[] charAarry = text.toCharArray();
for (int i = 0; i < charAarry.length; i++) {
map.put(charAarry[i] + "", 1);
}
return map.size();
}
This is what I did to calculate but I am still looking for any fast way. If anyone knows please answer.