#include
#include<string.h>
using namespace std;
int main() {
char a[1000];
cin>>a;
int l,k=1;
l=strlen(a);
char p=a[0];
cout<<p;
for(int i=1;i<l;i++)
{
char n=a[i];
if (i==l-1)
{
if(n==p)
{cout<<k+1;
break;}
else
{
cout<<k;
cout<<a[l-1]<<“1”;
break;
}
}
if (p==n)
{
k=k+1;
}
else
{
cout<<k;
cout<<a[i];
k=1;
}
p=a[i];
}
return 0;
}
String compression test case 1 failing
Your code is not producing correct result for the input as : q
Expected output : q1
Your output : q