Question: #include int main ( ) { int t; scanf ( % d , &t ) ; while ( t - - ) {

#include
int main()
{
int t;
scanf("%d", &t);
while(t--){
int n;
scanf("%d", &n);
char str[100];
for (int i =0; i < n; i++)
{
scanf("%c", &str[i]);
}
int tcount =0;
int pcount =0;
for (int i =0; i < n; i++)
{
if(str[i]=='\0')
{
break;
}
if (str[i]>='A' && str[i]<='Z')
{
str[i]= str[i]+32;
}
if (str[i]=='t')
{
tcount++;
}
if (str[i]=='p')
{
pcount++;
}
}
if (pcount > tcount)
{
printf("Pathaan
");
}
else if (pcount < tcount)
{
printf("Tiger
");
}
else
{
printf("Draw
");
}
}
return 0;
}
why this code on hackerrank giving me segmentation fault for few of the test cases

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!