1

We have to find an index 'x' such that the absolute difference between

(A[1]+A[2]+..+A[x]) and (A[x+1]+A[x+2]+..+A[n]) for some x ,

is minimized.

I came across this post.

Here the author has asked to minimize the produc of the subarrays, so in my question, I can take the logarithm of the array elements and the questions turn out to be equivalent to what I have asked

I was thinking of calculating the prefix sum array and the perform binary search on it. But the array elements go up to 10^19, and storing the sum may give a memory limit error.

Avi solanki
  • 53
  • 1
  • 6

0 Answers0