题解 | 字符个数统计

字符个数统计

https://www.nowcoder.com/practice/eb94f6a5b2ba49c6ac72d40b5ce95f50

关键点在于每个字符只统计一次

很明显需求就是去重,使用stl的set

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 2e5 + 5;
int __t = 1, n;
void solve() {
    string s;
    cin >> s;
    set<char> st;
    for (char c : s) {
        st.insert(c);
    }
    cout << st.size() << "\n";
}
int32_t main() {
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    //cin >> __t;
    while (__t--)
        solve();
    return 0;
}

 每日一题攒牛币,大厂offer不是梦,点我马上开始赚牛币

#牛客春招刷题训练营#

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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