In this HackerEarth Unique subsequences problem solution You are given a string S that contains N characters. Your task is to determine the maximum possible size of the subsequence T of S such that no two adjacent characters in T are the same.
HackerEarth Unique subsequences problem solution.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
string s;
cin>>s;
ll ans=0;
char last='-';
for(ll i=0;i<n;i++)
{
if(last != s[i])
{
last = s[i];
ans++;
}
}
cout<<ans<<"n";
}
return 0;
}