We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Time out in last three case
my C++ code is
int findMaxIndex(vector a,int n)
{
int c=INT_MIN,index;
for(int i=0;ic)
{
c=a[i];
index=i;
}
}
return index;
}
int main(){
int g,count;
cin >> g;
for(int a0 = 0; a0 < g; a0++){
int n;
count=0;
cin >> n;
vector a(n);
for(int i=0;i>a[i];
}
while(n!=0)
{
n=findMaxIndex(a,n);
count=count+1;
}
if(count%2==0)
cout<<"ANDY\n";
else
cout<<"BOB\n";
}
return 0;
}
any body can explian me , why ?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Gaming Array
You are viewing a single comment's thread. Return to all comments →
Time out in last three case my C++ code is int findMaxIndex(vector a,int n) { int c=INT_MIN,index; for(int i=0;ic) { c=a[i]; index=i; } } return index; } int main(){ int g,count; cin >> g; for(int a0 = 0; a0 < g; a0++){ int n; count=0; cin >> n; vector a(n); for(int i=0;i>a[i]; } while(n!=0) { n=findMaxIndex(a,n); count=count+1; } if(count%2==0) cout<<"ANDY\n"; else cout<<"BOB\n"; } return 0; } any body can explian me , why ?