You are viewing a single comment's thread. Return to all comments →
Simple Java solution
static int getMinimumCost(int k, int[] c) { Arrays.sort(c); int price = 0; int count = 0; for(int i=c.length-1 ;i>=0; i--){ price += (count/k+1)*c[i]; count++; } return price; }
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 →
Simple Java solution