Company: Oracle_19aug
Difficulty: medium
Minimum Cost to Convert Products Problem Description The manager of Amazon's fulfillment center is responsible for maintaining the inventory of a product in two variants, A and B, represented as 0 and 1 respectively. There are n products, where the i th product is represented by the array product[i] (if product[i] equals 1, the product is of type B. Otherwise, it is of type A). A positive integer k is also given, which specifies the length of the subarray that can be selected to convert a single element within that subarray to product A. Since variant B is no longer in demand, Amazon wants to convert all products in the array to variant A at the minimum cost, using the following operation as many times as needed. Choose two indices, l and r ( 0 ≤ l ≤ r < n ), such that r - l + 1 = k . The cost of this operation is product[l] + product[l+1] + ... + product[r-1] + product[r] . Choose an index p such that l ≤ p ≤ r and set product[p] to variant A (i.e., set it to 0). Given