Hi
I had one query. Here you take the pies one by one and solve it via greedy algorithm. What if one takes it rack by rack. That is, i choose the first rack, see how many pies can be positioned on it and choose the one with the highest weight, and iterate over it. I could not think of a case where it should not work. But i wanted your take on it too?
As the value of the number of pies and also the number of racks is equal to N.
So answer will never be greater than N so we can only check for number of pies fit into the racks
and print it.So that their is no need of checking of end of pies.If in case number of pies equals to N then all the racks get finished and answer will be N.
Means Simply as only one pies can be put in the rack if pies get finished rank will definitely get finished. So simply check for the end of racks and not about end of pies.