Greedy Florist

  • + 0 comments

    I find the most optimal solution of this question :) Just sort the array desc to asc and divide the index with k where u r geeting change in formulae

    def getMinimumCost(k, c):
        c.sort(reverse=True)
        sum=0
        for i in range(len(c)):
            sum+=(int(i/k)+1)*c[i]
        return sum