Codeforces Round 874 (Div. 3) 1833A. Musical Puzzle Solution
Problem Link : https://codeforces.com/contest/1833/problem/A
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 < string > st ;
- for ( int i = 0 ; i < n - 1 ; i++) {
- string cs = "" ;
- cs +=s[i] ;
- cs +=s[i+1] ;
- st.insert(cs) ;
- }
- cout << st.size() << endl ;
- }
- return 0;
- }
No comments