Company: Amazon_15may

Difficulty: medium

Problem Statement

Minimum Product Redistribution Cost Problem Description Amazon's warehouse management team is rolling out a standard that every Warehouse Manager must follow. A warehouse stores n identical containers arranged in a circle , so container n sits next to container 1 . The distance between two adjacent containers is 1 . Container i currently holds products[i] units. Products must be moved until every container holds the same number of units , under these rules: Pick one direction, clockwise or anti-clockwise , before any product is moved. Every product that moves must travel in that one direction; the direction never changes. A product may be carried past as many containers as needed, wrapping around the circle. Moving one product across one container boundary costs 1 . Moving it across d boundaries costs d . The total cost is the sum of the costs of all products moved. Report the minimum possible total cost, taken over both choices of direction. Input Format The first line contains an int

More Amazon_15may OA questionsInterview experiences