MohamedAbdel3al

Max Subsequence

Aug 22nd, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <bits/stdc++.h>
  4. using namespace std ;
  5. typedef long long ll ;
  6.  
  7. void ABDEL3AL () {
  8. ios_base::sync_with_stdio(false) , cin.tie(nullptr) , cout.tie(nullptr) ;
  9. #ifndef ONLINE_JUDGE
  10. freopen("input.txt" , "r" ,stdin) , freopen("output.txt" , "w" , stdout) ;
  11. #endif
  12. }
  13.  
  14. int main() {
  15. ABDEL3AL() ;
  16. int n , curr = 1 ;
  17. cin >> n ;
  18. string s;
  19. cin >> s ;
  20. for (int i = 1; i < s.size(); i++)
  21. if (s[i] != s[i - 1]) curr++ ;
  22. else curr++ ;
  23. cout << curr << "\n" ;
  24. return 0;
  25.  
  26. }
  27.  
  28.  
  29.  
Advertisement
Add Comment
Please, Sign In to add comment