#字符个数统计#__huawei_no.10-1
字符个数统计
https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50
#include <iostream> #include <unordered_map> #include <vector> using namespace std; int main() { string str; getline(cin,str); unordered_map<char ,int> map; int count = 0; for(char c : str){ if(map.count(c) == 0){ map[c] = 1; count++; } } cout<<count<<endl; return 0; } // 64 位输出请用 printf("%lld")
直接用哈希表统计的,还挺快;但是要辅助用一个count来记录。