You are viewing a single comment's thread. Return to all comments →
Came up with something similar agree it seemed very easy. I calculated my multiplier differently.
static int getMinimumCost(int k, int[] c) { Arrays.sort(c); int total = 0; for (int i = c.length - 1; i >= 0; --i) { int timesBought = ((c.length - 1) - i) / k; int price = c[i] * (timesBought + 1); total += price; } return total; }
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 →
Came up with something similar agree it seemed very easy. I calculated my multiplier differently.