Minimum Cost of Buying Candies with Discount

The customer can choose any candy to takeaway for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two candies bought. Find the minimum cost of buying all the candies. Implementation: Sort then Traverse def minimumCost ( self , cost : List [ int ]) -> int : cost . sort ( reverse = True ) minCost = 0 for i in range ( len ( cost )): if i % 3 != 2 :…