There are n containers arranged in a circle. Container i initially contains products[i] products.
Redistribute products so every container contains the same number of products. Moving one product across one edge costs 1.
For the entire redistribution process, choose one global direction, either clockwise or counter-clockwise. Every product that is moved must travel only in that chosen direction around the circle. Products cannot independently choose shorter paths in the opposite direction. For example, if clockwise is chosen, moving a product from position 3 to position 2 costs n - 1, not 1.
Return the minimum total movement cost over the two possible global directions.
products = [3, 4, 6, 6, 6] return = 7

products = [1, 11, 1, 1, 1] return = 20
The final average is 3. Container 1 has 8 extra products. Moving clockwise, send 2 products to each of the next four containers, for cost 2*1 + 2*2 + 2*3 + 2*4 = 20.
1 <= products.length <= 2 * 10^50 <= products[i] <= 10^9- The answer may exceed the 32-bit integer range.
- Count Promotional PeriodsOA · Seen Jun 2026
- Find Maximum Total Amount (SDE I, Fungible :)Seen Jun 2026
- Get Minimum AmountOA · Seen Jun 2026
- Get Smallest Base SegmentOA · Seen Jun 2026
- Select Least Resource TasksOA · Seen Jun 2026
- Product Category Group SizesPHONE SCREEN · Seen May 2026
- Count Connected ComponentsPHONE SCREEN · Seen May 2026
- Drone Delivery RouteOA · Seen May 2026
public long findMinimumCost(int[] products) {
// write your code here
}