Sunday, July 26, 2015

HackerRank::Algorithms::Greedy::Priyanka and Toys

  Actually there is no such a thing as optimal way of choosing the toys here ( more or less). Let's sort them out by the order of their weights. Now for the one which has the lowest weight, we need to buy that in any case, then we might get some bonus items after buying them, then the same goes for the remaining set of toys, we need to buy the one with the lowest weight in any case, and we might get a bonus if we are lucky, then the same thing again until we buy all of them.



No comments:

Post a Comment