Problem Here is what I tried:
#include<iostream>
#include<vector>
#include<string>
using namespace std;
using ll = long long;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n;
cin>>n;
string s;
cin>>s;
vector<ll> len, p;
ll i=0, j=0;
while(i<n && j<n)
{
while(j<n && s[i]==s[j])
j++;
p.push_back(j-i);
i=j;
}
ll ans = 0;
for(ll i=0; i<p.size(); ++i)
{
if(p[i]<2)
{
ans++;
i++;
}
else
ans++;
}
cout<<ans<<endl;
}
}
Can someone briefly explain where am I going wrong?