#字符个数统计#__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来记录。

全部评论

相关推荐

hwwhwh:同双非,有大厂实习其实也没啥用,主要看运气,等就行了
点赞 评论 收藏
分享
12-18 19:36
已编辑
门头沟学院 Java
程序员牛肉:可以的,简历没毛病了。 虽然还是偏向同质化,不过学历不错。后续我觉得重心放到刷实习+摆脱同质化问题上
实习简历求拷打
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务