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.
Approach 3 O(1), incomplete solution (failure of a test case), feel free to comment to share a way to complete it.
inthowManyGames(intp,intd,intm,ints){intn=1+(p-m)/d;inttotal=(p+p-(n-1)*d)*n/2;if(total<=s){returnn+(s-total)/m;}elsereturn0;// this return need to be computed properly}
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 →
Here are my approaches in c++, you can see the explanation here : https://youtu.be/VFVaLMRzhV4
Approach 1 O(n)
Approach 2 O(n) with recursion
Approach 3 O(1), incomplete solution (failure of a test case), feel free to comment to share a way to complete it.