Company: Amazon_29Aug
Difficulty: medium
Minimum Cost to Convert Products Problem Description A warehouse stocks n products in a row. Each product is one of two variants: product[i] = 0 means variant A and product[i] = 1 means variant B. Variant B is no longer in demand, so every product must be converted to variant A. A conversion is done with the following operation, which may be used as many times as needed: Choose two indices l and r with 0 <= l <= r < n and r - l + 1 = k , so the chosen subarray has exactly k products. The operation costs product[l] + product[l+1] + ... + product[r] , computed from the current values, that is, the number of variant B products in the subarray at that moment. Choose an index p with l <= p <= r and set product[p] to 0 (variant A). Find the minimum total cost to convert all the products in the array to variant A. Complete the function getMinimumCost(product, k) , which returns this minimum total cost. Input Format Read from standard input. n product[0] product[1] ... product[n