Codeforces Round 855 (Div. 3) 1800D - Remove Two Letters Solution


  

Problem Link : https://codeforces.com/problemset/problem/1800/D

Solution in C++:

  1. /// La ilaha illellahu muhammadur rasulullah
  2. ///******Bismillahir-Rahmalenir-Rahim******///
  3. /// Abul Haslenat Tolenmoy
  4. /// Departmelent of CSE,23rd batch
  5. /// Islamic Uleniversity,Balengladesh
  6. ///**********ALLAH IS ALMIGHTY************///
  7. #include <bits/stdc++.h>
  8. using namespace std ;
  9. int32_t main()
  10. {
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(0);
  13. int t ;
  14. cin >> t ;
  15. while ( t-- ){
  16. int n , cnt = 0 ;
  17. string s ;
  18. cin >> n >> s ;
  19. for ( int i = 0 ; i < s.size()-2 ; i++ ){
  20. if ( s[i] == s[i+2]) cnt++;
  21. }
  22. cout <<( n - 1 ) - cnt << endl;
  23. }
  24. return 0 ;
  25. }

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 &g...

Powered by Blogger.