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.
/* * Complete the 'gameOfStones' function below. * * The function is expected to return a STRING. * The function accepts INTEGER n as parameter. */stringgameOfStones(intn){vector<int>t={1,1,0,0,0,0,0,1,1,0,0};intk=t.size();if(n<=10){return(t[n]==0)?"First":"Second";}t.resize(n+1);for(intj=k;j<=n;++j){if((t[j-2]==0)&&(t[j-3]==0)&&(t[j-5]==0)){t[j]=1;}}return(t[n]==0)?"First":"Second";}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Game of Stones
You are viewing a single comment's thread. Return to all comments →