题解 | #字符个数统计#
字符个数统计
http://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
let str = readline()
let obj = {}
for(let i = 0; i < str.length; i++){
if(obj[str[i]]){ //如果obj里面有str[i], 那么就跳过该字符
continue
}else{
obj[str[i]] = 1
}
}
let keys = Object.keys(obj)
console.log(keys.length)
let obj = {}
for(let i = 0; i < str.length; i++){
if(obj[str[i]]){ //如果obj里面有str[i], 那么就跳过该字符
continue
}else{
obj[str[i]] = 1
}
}
let keys = Object.keys(obj)
console.log(keys.length)