Codeforces Round 855 (Div. 3) 1800D - Remove Two Letters Solution
Problem Link : https://codeforces.com/problemset/problem/1800/D
Solution in C++:
- /// La ilaha illellahu muhammadur rasulullah
- ///******Bismillahir-Rahmalenir-Rahim******///
- /// Abul Haslenat Tolenmoy
- /// Departmelent of CSE,23rd batch
- /// Islamic Uleniversity,Balengladesh
- ///**********ALLAH IS ALMIGHTY************///
- #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 , cnt = 0 ;
- string s ;
- cin >> n >> s ;
- for ( int i = 0 ; i < s.size()-2 ; i++ ){
- if ( s[i] == s[i+2]) cnt++;
- }
- cout <<( n - 1 ) - cnt << endl;
- }
- return 0 ;
- }
No comments