Codeforces Round 917 (Div. 2) 1917B - Erase First or Second Letter Solution
Problem Link : https://codeforces.com/contest/1917/problem/B
Solution in C++:
- /// Author : AH_Tonmoy
- #include <bits/stdc++.h>
- using namespace std;
- int32_t main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- while (t--) {
- int n ; cin >> n ;
- string s ; cin >> s ;
- set<char>st ;
- long long ans = 0 ;
- for (auto i : s){
- st.insert(i) ;
- ans += st.size() ;
- }
- cout << ans <<'\n';
- }
- return 0 ;
- }
No comments