Hassan is given a string containing characters A and B only. Your task is to change it into a string such that there are no matching adjacent characters. To do this, you are allowed to delete zero or more characters in the string.
#include<stdio.h>
#include<string.h>
int main()
{ char s[100001];
int t,count=0,i;
scanf("%d",&t);
while(t!=0)
{scanf("%s",s);
for(i=0;i<strlen(s);i++)
{if(s[i]==s[i+1])
count++; }
printf("%d\n",count); count=0; t--;} return 0;}
Comments
Post a Comment