Codeforces Round 917 (Div. 2) 1917B - Erase First or Second Letter Solution



 Problem Link :  https://codeforces.com/contest/1917/problem/B

Solution in C++:

  1. /// Author : AH_Tonmoy
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4. int32_t main() {
  5. ios_base::sync_with_stdio(0);
  6. cin.tie(0);
  7. int t;
  8. cin >> t;
  9. while (t--) {
  10. int n ; cin >> n ;
  11. string s ; cin >> s ;
  12. set<char>st ;
  13. long long ans = 0 ;
  14. for (auto i : s){
  15. st.insert(i) ;
  16. ans += st.size() ;
  17. }
  18. cout << ans <<'\n';
  19. }
  20. return 0 ;
  21. }

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.