Skip to content

Instantly share code, notes, and snippets.

@thinkphp
Created May 5, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thinkphp/208b74fbe3dad934c9606a9ea6bbac2b to your computer and use it in GitHub Desktop.
Save thinkphp/208b74fbe3dad934c9606a9ea6bbac2b to your computer and use it in GitHub Desktop.
Good String Problem from GeekforGeeks
#include <stdio.h>
int main() {
int t;
scanf("%d",&t);
while(t--)
{
char a, b, c;
char S[50];
scanf("%s",S);
char *ptr=S;
while(*(ptr+1)!='\0') {
a=*ptr;
b=*(ptr+1);
c=a-b;
if(c==1||c==-1||c==25||c==-25) {
ptr++;
continue;
} else {
printf("NO\n");
break;
}
ptr++;
}
ptr++;
if(*ptr=='\0') printf("YES\n");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment