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.
static int howManyGames(int p, int d, int m, int s) {
// Return the number of games you can buy
// Return the number of games you can buy
int numberOfGames = 0;
int i = p;
for ( i= p; i <= s; i += p)
{
numberOfGames++;
// d = p <= m ? m : d;
p = p < m || (p - d) <=0 || (p-d)<m ? m : p - d;
}
return numberOfGames;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Halloween Sale
You are viewing a single comment's thread. Return to all comments →
static int howManyGames(int p, int d, int m, int s) { // Return the number of games you can buy