HackerEarth Harry and String problem solution YASH PAL, 31 July 2024 In this HackerEarth Harry and String problem solution Harry was studying a magic book that categorizes the magic spells into 3 categories – Good , Worst and Bad. If any spell contains all the vowels in alphabetical order then that spell is categorized as Good. If it contains the vowels in reverse alphabetical order , then that spell is categorized as Worst. All the other spells that do not fall in any of the categories before are categorized as Bad. Now Harry tries to evaluate himslef by solving a spell categorization exercise at the end of the book , but since he is confused can you help him by solving the problems. HackerEarth Harry and String problem solution. #include <bits/stdc++.h>using namespace std;typedef long long int ll;typedef pair<ll, ll> pll;typedef vector<ll> vll;typedef vector<int> vi;#define pb push_backconst ll INF=1e18;const int mod=1000000007;char str[100009];int main(){ ll t,n,m,i,j,k; scanf ("%lld",&t); while (t--) { scanf ("%s",str); ll st[5],ed[5],f=0; for (i=0;i<5;++i) { st[i]=-1; ed[i]=-1; } for (i=0;str[i]!=' ';++i) { if (str[i]=='a') { if (st[0]==-1) st[0]=i; ed[0]=i; } else if (str[i]=='e') { if (st[1]==-1) st[1]=i; ed[1]=i; } else if (str[i]=='i') { if (st[2]==-1) st[2]=i; ed[2]=i; } else if (str[i]=='o') { if (st[3]==-1) st[3]=i; ed[3]=i; } else if (str[i]=='u') { if (st[4]==-1) st[4]=i; ed[4]=i; } } k=ed[0]; for (i=1;i<5;++i) { if (st[i]!=-1) { if (k<st[i]) k=ed[i]; else f=1; } } if (f==1) { k=ed[4]; for (i=3;i>=0;--i) { if (st[i]!=-1) { if (k<st[i]) k=ed[i]; else f=2; } } } if (f==0) puts ("Good"); else if (f==1) puts ("Worst"); else puts ("Bad"); } return 0;} coding problems