题解 | 字符个数统计
字符个数统计
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; }