sreyan32's blog

By sreyan32, history, 3 years ago, In English

Hi,

I need some help in the following problem.

Given a circular buffer of integers (positive/negative), what is the minimum number of conversions (addition/subtraction by 1) on elements so that all K subarrays have the same sum. The cost of each conversion is 1.

Constraints:

  1. The input array represents a circular array.
  2. The numbers in the array can be positive or negative integers.

Example:

N = 10 (size of the array)
K = 1 (size of the subarrays)
array = [1,2,3,4,5,6,7,8,9,10]

Output is 25 (changing all the values to 5 satisfies the constraints)

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it