Advertisement
Bassel_11

Untitled

Aug 29th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void MaxSubsequence () {
  5.  
  6.     int size;
  7.     cin>>size;
  8.     string value;
  9.  
  10.     cin>>value;
  11.     char temp;
  12.     int counter = 0;
  13.     for(int i=0;i<size;i++){
  14.         if(i == 0){
  15.             temp = value[i];
  16.             counter++;
  17.         } else {
  18.             if(value[i] != temp){
  19.                 counter++;
  20.                 temp = value[i];
  21.             }
  22.         }
  23.     }
  24.     cout<<counter;
  25. }
  26. int main() {
  27.     MaxSubsequence();
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement