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

很明显需求就是去重,使用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不是梦,点我马上开始赚牛币

#牛客春招刷题训练营#