Back to problems

Minimum Redistribution Cost

Algorithm · Amazon · Hard

You are given n warehouses positioned around a circle and labeled from 0 through n - 1. Moving clockwise from warehouse i leads to warehouse (i + 1) % n. Warehouse i starts with products[i] units, and the total number of units is guaranteed to be divisible by n. Redistribute the units so that all warehouses finish with an equal amount. All transfers must use one common direction: choose either clockwise or counterclockwise, and use that direction for every movement. A unit…

Checking your access…