Get Min Moves
Problem Overview
- Find the minimum moves to equalize totals of two consignments by increasing or decreasing item counts by 1, keeping each quantity positive.
- Input: quantity[n]; choose j with 1<=j<n to split types [1..j] and [j+1..n]; Output: long_int minimum moves over all valid splits.
- Context: a shop ships inventory in two consignments, keeping all units of a type together.
- Asked in Ibm interviews; a coding interview problem and interview question on array partitioning and balance.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
