Ice Cream Stock Warehouse Balancing
Ice Cream Stock Warehouse Balancing
MediumArrays0% accepted
Meera manages N regional ice cream warehouses. Stock levels are unbalanced due to seasonal demand. Adjacent warehouses should have stock within D units of each other. Find minimum stock transfers needed.
Approach
Given stock array and max difference D, find minimum transfers between adjacent warehouses to satisfy |stock[i] - stock[i+1]| ≤ D.
Input
4 5
10 20 30 40
Output
20
More Arrays problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards