Company: Walmart_12march
Difficulty: medium
Pairwise Product Sum Problem Description You are given an array arr of n positive integers, where n is even. The array is read as n/2 mirrored pairs: index 0 with index n-1, index 1 with index n-2, and so on. You may perform the following operation any number of times, including zero: Select an index i with 0 <= i <= n/2 - 1. Either increase arr[i] by 1 and decrease arr[n-i-1] by 1, or decrease arr[i] by 1 and increase arr[n-i-1] by 1. Each such move counts as one operation, and the same index may be selected any number of times. Your goal is to maximise the value of f(arr) = sum over i = 0 .. n/2 - 1 of (arr[i] * arr[n-i-1]) Among all sequences of operations that reach the maximum possible value of f(arr), report the length of a shortest one. (inferred - the source writes the upper limit of the sum as n/2, which would reuse index n/2 in a second pair. Sample 1 has f([2,2,3,3]) = 12 = 2*3 + 2*3, which is the sum over i = 0 .. n/2 - 1 only; the limit is therefore n/2 - 1.) Input F