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.
For stopping early, you can use a recursive function, that stops when the max number of mangoes is reached. I also made the solution in scala and ran into the timeouts as well. Unfortunately this will not solve your timeouts.
I made two improvements in the calculation to get rid of the timeouts. I can give some hints:
1. It is not strictly neccesarry to consider all combinations
2. You don't necessarily have to start with 1 invitation first.
Good luck!
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Mangoes
You are viewing a single comment's thread. Return to all comments →
For stopping early, you can use a recursive function, that stops when the max number of mangoes is reached. I also made the solution in scala and ran into the timeouts as well. Unfortunately this will not solve your timeouts.
I made two improvements in the calculation to get rid of the timeouts. I can give some hints: 1. It is not strictly neccesarry to consider all combinations 2. You don't necessarily have to start with 1 invitation first.
Good luck!