-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathfind-hackerrank.c
More file actions
55 lines (52 loc) · 793 Bytes
/
find-hackerrank.c
File metadata and controls
55 lines (52 loc) · 793 Bytes
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
//https://www.hackerrank.com/challenges/find-hackerrank
//mandeep singh @msdeep14
#include<stdio.h>
#include<string.h>
int main()
{
int i,j,k,t,n,flag1,flag2;
char str[5000];
char str1[10]={'h','a','c','k','e','r','r','a','n','k'};
scanf("%d",&t);
gets(str);
while(t--)
{
flag1=0;
flag2=0;
gets(str);
n=strlen(str);
for(i=0;i<10;i++)
{
if(str[i]==str1[i])
{
//do nothing;
}
else
{
flag1=1;
break;
}
}
for(i=n-1,j=9;i>=(n-10),j>=0;i--,j--)
{
if(str[i]==str1[j])
{
//do nothing;
}
else
{
flag2=1;
break;
}
}
if(flag1==0 && flag2==0)
printf("0\n");
else if(flag1==0 && flag2==1)
printf("1\n");
else if(flag1==1 && flag2==0)
printf("2\n");
else
printf("-1\n");
}
return 0;
}