Back to problems

Get Minimum Changes

Algorithm · Amazon · Medium

Problem Amazon is updating its inventory system with an operation that changes product prices. The price of product i is stored in prod_price[i]. Determine the fewest price changes needed so that every contiguous subarray of length k has the same sum. A price-change operation may replace any number of entries in prod_price with positive integers. Given prod_price and a positive integer k, return the minimum number of entries that must be changed to make the sums of all…

Checking your access…