Codeforces Round 874 (Div. 3) 1833A. Musical Puzzle Solution


 

Problem Link :  https://codeforces.com/contest/1833/problem/A

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 ;
  11. cin >> n ;
  12. string s ;
  13. cin >> s ;
  14. set < string > st ;
  15. for ( int i = 0 ; i < n - 1 ; i++) {
  16. string cs = "" ;
  17. cs +=s[i] ;
  18. cs +=s[i+1] ;
  19. st.insert(cs) ;
  20. }
  21. cout << st.size() << endl ;
  22. }
  23. return 0;
  24. }

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

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

Powered by Blogger.