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.