Company: JPMorgan Chase

Difficulty: easy

Problem Statement

Balance the Two Consignments A shop has n item types. The quantity of the i -th item type is quantity[i] , using 1-based indexing in this description. The items must be shipped in two consecutive consignments split by an index j : the first consignment contains item types 1, 2, ..., j , and the second contains item types j + 1, ..., n . You may choose any j with 1 <= j < n , so both consignments are non-empty. In one operation you may increase or decrease any quantity[i] by 1 . Quantities must remain positive at all times. Return the minimum number of operations needed to make the total quantity of the first consignment equal to the total quantity of the second, choosing the split optimally. Function Complete the function getMinimumOperations : getMinimumOperations(quantity: int[]) -> long int quantity[n] : the quantities of each item type Returns long : the minimum number of operations required to make the two sums equal under an optimal division. Input Format The first line

More JPMorgan Chase OA questionsInterview experiences