题解 | #字符个数统计#
字符个数统计
http://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
1. 思路就是去重+计算字符串长度
2. set的不重复性质去重也可以
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String str = sc.nextLine(); StringBuffer ans = new StringBuffer(); for(int i = 0; i<str.length(); i++){ if(!ans.toString().contains(str.substring(i,i+1))){ ans.append(str.substring(i,i+1)); } } System.out.println(ans.toString().length()); } }