Company: Amazon_31_Dec
Difficulty: medium
Maximize Median with Operations Description Amazon's Data Analysts are studying how adjusting data values impacts model training performance. Their goal is to maximize the median of a given dataset through a series of controlled modifications. You are given an array data of n integers and an integer weight , which is used in the modification process defined below. Modification Process You need to perform exactly k operations, where in each operation: Choose two different indices i and j in the array such that ( i ≠ j ) and ( 0 ≤ i, j ≤ n-1 ). Increase data[i] by the weight value, i.e., assign data[i] = data[i] + weight . Decrease data[j] by the weight value, i.e., assign data[j] = data[j] - weight . After the first operation, the subsequent operation is performed on the modified data array. Objective Apply exactly k operations, in such a way that maximizes the median of the array. Given the array data of length n , and an integer weight , determine the maximum possible median