牛客华为机试题库【题号 HJ开头】(重点看)
牛客在线编程算法篇【题号NC开头】
剑指offer【题号 JZ开头】
力扣
1)原题链接
2)已有题解
3)代码
package collections;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;
import static java.lang.System.in;
/**
* HJ10 字符个数统计
*/
public class CharacterCountStatistics {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
String str = bf.readLine();
bf.close();
Set<Character> set = new HashSet<>();
char[] chars = str.toCharArray();
for (int i = 0; i < chars.length; i++) {
if (0 <= chars[i] && chars[i] <= 127) {
set.add(chars[i]);
}
}
System.out.println(set.size());
}
}