You are viewing a single comment's thread. Return to all 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
Seems like cookies are disabled on this browser, please enable them to open this website
Greedy Florist
You are viewing a single comment's thread. Return to all 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