Company: Amazon_31_Dec
Difficulty: medium
Maximize Median with Operations Problem 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 must perform exactly k operations. In each operation you: Choose two different indices i and j with i != j and 0 <= i, j <= n - 1 . Increase data[i] by weight , that is data[i] = data[i] + weight . Decrease data[j] by weight , that is data[j] = data[j] - weight . Every operation after the first one is performed on the already modified array. Values are not bounded during the process: an element may become 0 or negative. Objective Apply exactly k operations so that the median of the resulting array is as large as possible, and return that median. Note: the median of an array is defined as