Aaron has a number D containing only digits 0's and 1's. He wants to make the number to have all the digits same. For that, he will change exactly one digit, i.e. from 0 to 1 or from 1 to 0.
#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main()
{
int t,n1,n0,len,i;
char str[100002];
scanf("%d",&t);
while(t--){
scanf("%s",str);
n1=n0=0;
len=strlen(str);
for(i=0;i<len;i++){
if(str[i]=='0')
++n0;
else
++n1;
}
if(n1==len-1 || n0==len-1)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
Comments
Post a Comment