Company: JPMC_20july
Difficulty: medium
Minimum Operations to Balance Consignments Problem Description A shop stocks n types of items. The quantity of the i-th type is quantity[i] . The whole stock is shipped as exactly two consignments, split at a position j : the first consignment holds item types 1, 2, ..., j the second consignment holds item types j + 1, ..., n The split position j may be any value with 1 <= j < n (1-based indexing), so both consignments are non-empty and every item type stays entirely inside one consignment. The order of the item types is fixed and may not be rearranged. The shopkeeper wants the two consignments to hold the same total quantity. To achieve this, they may repeatedly pick any single item type and increase or decrease its quantity by 1 . Each such change counts as one operation, and the quantity of every item type must stay positive (at least 1 ) at all times. Report the minimum total number of operations needed, given that the split position j may also be chosen in the way that is be