forked from DPrinceKumar/HacktoberFest2020-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhappy_ladybugs.c
73 lines (71 loc) · 1.5 KB
/
happy_ladybugs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int min(int a,int b){
if(a>b){
return b;
}
else {
return a;
}
}
int main()
{
int t;
scanf("%d",&t);
for(int a0=0;a0<t;a0++){
int n;
scanf("%d",&n);
int flag=0;
char* b=(char*)malloc(n*sizeof(char));
int* a=calloc(26,sizeof(int));
char x;
scanf("%c",&x);
for(int i=0;i<n;i++){
char x;
scanf("%c",&x);
if(x=='_'){
flag=1;
}
else{
a[(int)x-65]++;
}
b[i]=x;
}
int c=0;
if(flag==1){
for(int i=0;i<26;i++){
if(a[i]==1){
c=1;
break;
}
}
if(c==0){
printf("YES\n");
continue;;
}
else {
printf("NO\n");
continue;
}
}
else{
for(int i=0;i<n;i++){
if(b[i]!='_'&&b[i]!=b[i-1]&&b[i]!=b[i+1]){
printf("NO\n");
c=1;
break;
}
}
if(c==0){
printf("YES\n");
}
}
}
}