Monday, 31 August 2020

String Game Hacker Earth Solution in C

https://www.hackerearth.com/practice/basic-programming/implementation/basics-of-implementation/practice-problems/algorithm/alice-and-string-game-dbd6adc3/submissions/

#include<stdio.h>
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        char s[100001];
        int i,h[26]={0},c=0;
        scanf("%s",s);
        for(i=0;s[i] != '\0'; i++)
            h[s[i]-'a']++;
        for(i=0;i<26;i++)
        {
            if(h[i]!=0)
                c++;
        }
        if(c%2!=0)
            printf("Player1\n");
        else
            printf("Player2\n");
    }
}

No comments:

Post a Comment