题解 | #字符个数统计#
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String zfc = fzhinput.nextLine(); int i; StringBuilder stack = new StringBuilder(); Set<Character> unseen = new HashSet<>(); for(i=0;i<zfc.length();i++){ char c = zfc.charAt(i); if(!unseen.contains(c)){ stack.append(c); unseen.add(c); } } System.out.println(stack.length()); } }