Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

#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

Step: 1

blur-text-image
Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students explore these related Databases questions