Sort the array and buy candies in groups of 3 from the most expensive side. For every 3 candies, the cheapest one becomes free.
// A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free. // The customer can choose any candy to take away for free as long as the cost of the ...