Minimum number of conversions in a circular buffer so that all K subarrays will have equal sum ?

Revision en1, by sreyan32, 2022-04-10 20:24:04

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)
Tags array, circulararray

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English sreyan32 2022-04-10 20:24:04 696 Initial revision (published)